Check for featured image in WP_Query

Technically featured image is custom field with name _thumbnail_id that holds attachment ID. So you can easily query with something like:

$args = array(
    'meta_query' => array(
        array(
            'key' => '_thumbnail_id',
        )
    )
 );
$query = new WP_Query( $args );

Size on other hand is attribute of that attachment and not post itself. You will need to loop through attachment and get sizes they have (if I remember right it should be in data returned by wp_get_attachment_metadata()).

Leave a Comment