I have following code:

$posts = get_posts(array(
  "meta_key" => "special",
  "meta_value" => "surprise",
  // "has_post_thumbnail" => true, // how to do that?

What should I do to select posts having post thumbnails?

1 Answer 1


The thumbnail is stored as a meta with a key of _thumbnail_id, so that could be used to find posts that have thumbnails. Something like this:

$query = new WP_Query(array(
    'meta_query' => array( array( 
        'key' => '_thumbnail_id',
        'value' => '0',
        'compare' => '>=',

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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