Is it possible to retreive the current post (inside the loop) featured image ID?

The reason why I want this is so I can do something like this...


$featuredID = //get the featured image id

echo do_shortcode('[gallery size="thumbnail" link="file" exclude="' . $featuredID . '"]');  


Any help would be great thanks!


Sounds like you're looking for get_post_thumbnail_id():

$featuredID = get_post_thumbnail_id();

It returns null if there's not a featured image, so you may want to add a check for that.


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.