Last active
August 29, 2015 14:21
-
-
Save itailulu/4f4a0627ccb9bc20c5fc to your computer and use it in GitHub Desktop.
Add filter to only load posts with thumbnails when the "show thumbnail" option is selected
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
add_filter('upw_wp_query_args', 'upw_only_posts_with_thumbnails',10 , 2); | |
function upw_only_posts_with_thumbnails($args, $instance) { | |
if ( $instance['show_thumbnail'] ) { | |
$args['meta_query'] = array( | |
array( | |
'key' => '_thumbnail_id', | |
'compare' => 'EXISTS' | |
) | |
); | |
} | |
return $args; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment