Find posts without featured image?

Nut-Nights

Elite Member
Executive VIP
Jr. VIP
Joined
Jun 20, 2013
Messages
11,549
Reaction score
8,755
Any wordpress plugin for this ?
 
Did this work? I have a site where I could use this myself.
 
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 im.ID IS NULL
AND p.post_content NOT REGEXP 'src=".*"'

last code will remove posts which includes images inside it.
 
or try this:

$args = array(
'meta_query' => array(
array(
'key' => '_thumbnail_id',
'value' => '?',
'compare' => 'NOT EXISTS'
)
),
);
$new_query = new WP_Query( $args );


in WP_Query()
This must work.
 
@trademysite that plugin didnt work and i already check that code on stack exchange, but i am not technical guy to use codes.

I forget to mention my site got 20k + posts.
 
Using the codes is very simple, just login to your mySQL and run the query.
 
Back
Top