Skip to content

Instantly share code, notes, and snippets.

<?php
public function render_summary_report_widget() {
$not_hidden_queries = array(
'companies-dont-test' => array(
'post_type' => 'company',
'posts_per_page' => -1,
'suppress_filters' => 0,
'meta_query' => array(
array(
'key' => 'animal_testing_policy',
@donaldG
donaldG / author.php
Last active October 24, 2017 13:14
modify facebook instant articles author
<?php
function filter_instant_articles_author_info( $authors ) {
$authors = '';
return $authors;
}
add_filter( 'instant_articles_authors', 'filter_instant_articles_author_info', 10, 1 );
//again, maybe you can just return nothing?
@donaldG
donaldG / kicker.php
Last active October 24, 2017 13:14
change facebook instant articles kicker
<?php
function filter_instant_articles_category_kicker( $category ) {
$category = '';
return $category;
}
add_filter( 'instant_articles_cover_kicker', 'filter_instant_articles_category_kicker', 10, 1 );
//maybe you can do this and return nothing?
@donaldG
donaldG / replace_srcset.php
Last active March 20, 2017 16:22
Replace WordPress srcset on local with live
<?php
//this goes in the bottom of your LOCAL config file
//these should already be set but in case they aren't:
//$env = $_SERVER['SERVER_NAME'];
//$domain = 'yourSiteName/';
//$local_url = 'http://' . $env . '/' . $domain;
//define('WP_ENV', $env);
//define('WP_HOME', $local_url);
//define('WP_SITEURL', $local_url);
@donaldG
donaldG / woocommerce.php
Last active January 4, 2016 14:07
a little function to display credit for woocommerce
<?php
function woocommerce_subcategory_thumbnail( $category ) {
$small_thumbnail_size = apply_filters( 'single_product_small_thumbnail_size', 'shop_catalog' );
$dimensions = wc_get_image_size( $small_thumbnail_size );
$thumbnail_id = get_woocommerce_term_meta( $category->term_id, 'thumbnail_id', true );
if ( $thumbnail_id ) {
$image = wp_get_attachment_image_src( $thumbnail_id, $small_thumbnail_size );
$image = $image[0];
@donaldG
donaldG / surname-sort.php
Last active September 17, 2015 15:56
sort alphabetically by last name if post title is a name
<?php
$args = array(
'post_type' => 'post',
'posts_per_page' => -1,
);
$the_posts = get_posts($args);
foreach($the_posts as $single_post){
$single_id = $single_post->ID;
<script>
jQuery(document).ready(function($) {
$('iframe[src*="youtube.com"]').wrapAll('<div class="youtube-wrapper">');
$('.youtube-wrapper').wrapAll('<div class="video-player">');
});
</script>
<style>
.video-player {
clear: both;
<?php
/**
* Seems like this is the best way to remove Foobox where it's not needed. According to this blog post the js file name changes,
* but it seems like they've made it consistent. However, I couldn't seem to get the CSS to go away.
* http://blackhillswebworks.com/2013/03/13/load-foobox-plugin-scripts-and-styles-only-when-needed/
* Foobox told me on Twitter to try using the 'Exclude Foobox' button on the page itself, but it didn't give me the results I wanted:
* https://twitter.com/foobox/status/595741740994297856
* @don
*/
add_action( 'wp_print_scripts', 'disable_foobox_script', 100 );
<!doctype html>
<html>
<head>
<title>Create wp-config.php file!</title>
<style type="text/css">
label,
input{
display:block;
width:50%;
font-size:150%;
<?php
function filter_image_url($url){
$liveurl = 'http://www.siteurl.com/';
$localurl = 'http://localhost/yourURL/';
$url = str_replace($localurl, $liveurl, $url);
return $url;
}
add_filter('wp_get_attachment_url', 'filter_image_url');