WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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!

share|improve this question
up vote 6 down vote accepted

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.

share|improve this answer
THis is perfect thanks!!! – Joshc Aug 18 '12 at 0:06

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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