This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'pre_get_posts', 'the_dramatist_filter_pre_get_posts' ); | |
function the_dramatist_filter_pre_get_posts( $query ) { | |
if( is_admin() && $query->is_main_query() && in_array( $query->get('post_type'), array('shop_order') ) ) { | |
add_filter( 'posts_join', 'the_dramatist_filter_pre_get_posts_query_join' ); | |
add_filter( 'posts_where', 'the_dramatist_filter_pre_get_posts_filter_date' ); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* How to filter the value that would be returned by get_post_thumbnail_id() | |
*/ | |
add_filter( 'get_post_metadata', function ( $value, $post_id, $meta_key, $single ) { | |
// We want to pass the actual _thumbnail_id into the filter, so requires recursion | |
static $is_recursing = false; | |
// Only filter if we're not recursing and if it is a post thumbnail ID |