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.

  • 1
    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. May 20, 2011 at 17:54

4 Answers 4


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
  • 3
    This is an accurate answer and must be upvoted.
    – gurung
    Apr 20, 2014 at 15:05
  • Dear god my eyes are bleeding. Sadly that's the right answer, in Wordpress everything and their mother is a post.
    – marek.m
    Apr 29, 2019 at 12:52
  • get_post(get_post_thumbnail_id())->post_title (in contrast to @mfgmicha's the_post_thumbnail_caption()) displays filename without extension, not the text entered into "Title" field in media gallery
    – Fanky
    Dec 5, 2022 at 13:48


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

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


Since WordPress 4.6 there are new functions for the post thumbnail caption

Get caption text: (Doc link)

// return the caption text without any html markup

Output caption text: (Doc link)

// echo the caption text without any html markup

You can add a specific post as object or id as parameter. Without (like shown above) WordPress uses the current post.


Try this code to get thumbnail title:

echo get_post(get_post_thumbnail_id())->post_title; 

Don't forget to add open and close PHP tag.

  • Are you certain this gets the title attribute of a post thumbnail?
    – Christine Cooper
    Sep 11, 2020 at 7:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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