I need way to find post(s) without featured image set. I use WP as gallery site and for every post I set featured image. I wish to check if there is any post(s) without featured image.

Any code to paste on same custom page template to list post(s) (if any) without featured image?


You can use this plugin https://wordpress.org/plugins/quick-featured-images/

In description it says "You can also see posts with no featured image at a glance."

But from code side, wordpress manages images, documents any media by creating an attachment post for holding the information about that media and it's relation (if any) with other post/posts, which means you need sql query to find all posts without any images attached. To retrieve all posts without any image attached you can execute a query like this:

SELECT DISTINCT(p.ID), p.post_title, p.post_content FROM `wp_posts` p
LEFT JOIN wp_posts im ON p.ID = im.post_parent AND im.post_type = "attachment" 
WHERE p.post_status ='publish' 
AND p.post_type = "post" 
AND p.post_content NOT REGEXP 'src=".*"' 

last code will remove posts which includes images inside it.

Not the answer you're looking for? Browse other questions tagged or ask your own question.