Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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...

<?php

$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
add comment

1 Answer 1

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
add comment

Your Answer

 
discard

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.