Skip to content

Instantly share code, notes, and snippets.

@itailulu
Last active August 29, 2015 14:21
Show Gist options
  • Save itailulu/4f4a0627ccb9bc20c5fc to your computer and use it in GitHub Desktop.
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
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