Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wordpress. Get posts without featured image only

Tags:

wordpress

I know we can filter posts with a featured image by using

'meta_query' => array(
    array( 'key' => '_thumbnail_id'), 
)

in WP_Query()

But how do I get posts without featured image?

like image 968
Paradoxetion Avatar asked Dec 14 '22 10:12

Paradoxetion


1 Answers

Try this?

$args = array(
  'meta_query' => array(
     array(
       'key' => '_thumbnail_id',
       'value' => '?',
       'compare' => 'NOT EXISTS'
     )
  ),
);
$new_query = new WP_Query( $args );
like image 125
Tania Rascia Avatar answered Jan 05 '23 08:01

Tania Rascia