Title: Query Posts WITHOUT Featured Image
Last modified: October 14, 2016

---

# Query Posts WITHOUT Featured Image

 *  [Alkorr](https://wordpress.org/support/users/alkorr/)
 * (@alkorr)
 * [9 years, 7 months ago](https://wordpress.org/support/topic/query-posts-without-featured-image/)
 * Hi, I would like to query posts which don’t have a featured image. I searched
   Google and the WP Forums with no success so far… All I can find is how to query
   posts WITH featured images…
 * I tried this code but I can’t make it work like I want:
 *     ```
       	'post__not_in' => array( $thumb_id ),
       	'exclude'     => get_post_thumbnail_id($id)
       ```
   
 * Thanks for your help!

Viewing 6 replies - 1 through 6 (of 6 total)

 *  [Adarsh Verma](https://wordpress.org/support/users/shobhit2412/)
 * (@shobhit2412)
 * [9 years, 7 months ago](https://wordpress.org/support/topic/query-posts-without-featured-image/#post-8298671)
 * Hi [@alkorr](https://wordpress.org/support/users/alkorr/),
    One thing you can
   do is, just add this condition check when the looping of the posts starts:
 * <?php if( !has_post_thumbnail() ){?> //Just after the loop starts
    —-POST CONTENT—-
   <?php }?> //Just before the loop ends
 * This will only print the posts that will not have the featured images.
 * Thanks!
 *  Thread Starter [Alkorr](https://wordpress.org/support/users/alkorr/)
 * (@alkorr)
 * [9 years, 7 months ago](https://wordpress.org/support/topic/query-posts-without-featured-image/#post-8299084)
 * Hi Shobhit, thank you, it works but there is a downside to this code: not all
   my posts have a featured image, so I have a first loop in which I show 2 posts
   containing a featured image. It works fine. Now when I use your code to show 
   2 other posts with no featured image, I have to query 4 posts to get 2 showing…
   I guess it’s because your code ‘skips’ the posts with the featured image to only
   show the ones without it. If I query 2 posts, only one is showing. And since 
   I’m not a coder, I have no idea how to make the query work properly.
 * Thanks again for your help 😉
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [9 years, 7 months ago](https://wordpress.org/support/topic/query-posts-without-featured-image/#post-8300645)
 * try with:
 *     ```
       $args = array( 
       	'meta_key' => '_thumbnail_id', 	
       	'meta_compare' => 'NOT EXISTS'
       ) 
   
       $no_featured_image = new WP_Query( $args );
       while ( $no_featured_image->have_posts() ) : $no_featured_image->the_post();
       ETC.....
       ```
   
 * [https://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters](https://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters)
 *  Thread Starter [Alkorr](https://wordpress.org/support/users/alkorr/)
 * (@alkorr)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/query-posts-without-featured-image/#post-8348366)
 * Hi Michael, thanks for your help but it doesn’t work, the query breaks my page,
   it’s all blank now…
 * Here’s my code:
 *     ```
       <?php $args = array( 
       	'posts_per_page' => 2,
       	'post__not_in' => get_option( 'sticky_posts' ),
       	'meta_key' => '_thumbnail_id', 	
       	'meta_compare' => 'NOT EXISTS') 
   
       $no_featured_image = new WP_Query( $args );
       while ( $no_featured_image->have_posts() ) : $no_featured_image->the_post();
       ?>
   
       My text
   
       <?php endwhile; ?>
       <?php wp_reset_query(); ?>
       ```
   
 * I don’t know what’s wrong… 🙁
    -  This reply was modified 9 years, 6 months ago by [Alkorr](https://wordpress.org/support/users/alkorr/).
    -  This reply was modified 9 years, 6 months ago by [Alkorr](https://wordpress.org/support/users/alkorr/).
 *  [MyThemeShop](https://wordpress.org/support/users/mythemeshop/)
 * (@mythemeshop)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/query-posts-without-featured-image/#post-8348434)
 * Hello,
 * There’s a syntax error with your code. Try
 *     ```
       <?php $args = array( 
       	'posts_per_page' => 2,
       	'post__not_in' => get_option( 'sticky_posts' ),
       	'meta_key' => '_thumbnail_id', 	
       	'meta_compare' => 'NOT EXISTS'
       );
   
       $no_featured_image = new WP_Query( $args );
       while ( $no_featured_image->have_posts() ) : $no_featured_image->the_post();
       ?>
   
       My text
   
       <?php endwhile; ?>
       <?php wp_reset_query(); ?>
       ```
   
 * I hope that helps.
 *  Thread Starter [Alkorr](https://wordpress.org/support/users/alkorr/)
 * (@alkorr)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/query-posts-without-featured-image/#post-8348462)
 * Hi, it works great, thank you both very much for your help! 🙂

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Query Posts WITHOUT Featured Image’ is closed to new replies.

## Tags

 * [featured image](https://wordpress.org/support/topic-tag/featured-image/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 6 replies
 * 4 participants
 * Last reply from: [Alkorr](https://wordpress.org/support/users/alkorr/)
 * Last activity: [9 years, 6 months ago](https://wordpress.org/support/topic/query-posts-without-featured-image/#post-8348462)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
