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.

In my theme I want to display the featured image, but I also want to display the title attribute (of the image, not of the post/page) beside the image itself.

Is there a simple way to do this? Where should I be looking?

Thanks, John.

share|improve this question
    
Can you mark your question as answered since you found the solution. You can answer your own question. This removes it from the unanswered list. –  xLRDxREVENGEx May 20 '11 at 17:54
add comment

2 Answers

post_excerpt is actually the caption attribute. Here is the correct answer:

$title = get_post(get_post_thumbnail_id())->post_title; //The Title
$caption = get_post(get_post_thumbnail_id())->post_excerpt; //The Caption
$description = get_post(get_post_thumbnail_id())->post_content; // The Description
share|improve this answer
    
This is an accurate answer and must be upvoted. –  gurung Apr 20 at 15:05
add comment

Easy!

<?php the_post_thumbnail();
echo get_post(get_post_thumbnail_id())->post_excerpt; ?>

Taken from: http://www.billerickson.net/wordpress-featured-image-captions/

share|improve this answer
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.