Only Show Posts that Has Featured Image

Only Show Posts that Has Featured Image

Lets query the 6 recent posts simply, use class WP_Query to create a new posts query:

It works well. But sometimes I only want to show the posts that has been set featured image. It is very easy to implement. Set meta_key parameter to WP_Query, See:

It will only display the posts that has featured image.
If you only want to show posts that has featured image in home, use pre_get_posts hook, see:

Or only in category, function wphigh_featured_image_posts() change to:

Only in specific category ID:

Comments are closed.