Lets say I have the ID of an image. Is there a way that I get all the posts that have that image as their featured image?


The featured image is stored as post meta with the key _thumbnail_id, so you could use a meta query to get posts with a specific thumbnail:

$posts = new WP_Query( array( 
    'meta_query' => array(
            'key'   => '_thumbnail_id',
            'value' => $attachment_id,
) );

Where $attachment_id is the ID of the image.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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