Beginner's Guide for WordPress - Start your WordPress Blog in minutes.
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
WordPress Plugins
View all Guides

How to Display WordPress Post Thumbnails with Captions

Last updated on by
Special WordPress Hosting offer for WPBeginner Readers
How to Display WordPress Post Thumbnails with Captions

WordPress has this amazing feature known as Post Thumbnails also referred to as Featured Images. When uploading a post thumbnail, you are asked to add a caption, description, along with other fields, but when you get ready to display it, it only shows the image. In this article, we will share a small trick that will let you display captions or entire image descriptions with your post thumbnail.

First thing first, you need to enable Post Thumbnails in your WordPress Theme. Now, when you upload an image using the media uploader, you will see something like this:

Add an Image

You will need to go ahead and fill all of the information. Now one thing that many folks do not know is that WordPress stores each image as its own post. So the Title of the Image will be the title of the post, Caption will be the excerpt of the post, and Description will be the content of the post. So you can display all of these information when you are displaying your WordPress Thumbnail.

To display your post thumbnail with its caption, simply paste the following code inside the loop:

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

You can obviously style it the way you want to style it.

You can also display entire image description by adding this code inside the post loop:

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

This really simple trick can go long way in styling your next custom WordPress theme.

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi. Page maintained by Syed Balkhi.

WPBeginner's Video Icon
Our HD-Quality tutorial videos for WordPress Beginners will teach you how to use WordPress to create and manage your own website in about an hour. Get started now »


  1. Zlatev says:

    Built-in in 4.6 –

  2. Frank says:

    no alt text????

  3. zaib azhar says:

    in which file?

  4. Moyen says:

    I tried to get the featured image by calling the specific post ID and get_post function but everything is okay except featured image. It does not show featured image.

    is there problem to call by post ID and get_post(); ?

    my code?

    // custome template (community)

    post_title; ?>

    post_content; ?>

    Please any idea?

  5. Sabir says:

    This is very great and very helpful. Thank you so much!

  6. Trisha says:

    Thank you for explaining this! I just needed to add the image captions and spent a lot of time searching for a solution…..I found a lot of other answers on the WP support forum, but none of them explained how featured images are stored……such a simple thing now that I understand.

  7. Vali_REK says:

    Hello, great post.
    Please explain if I can do that in other website.
    I d like to show article or category from wordpress blog on opencart website.
    Thank you

  8. Aneas Nemorosus says:

    Where can I buy you a coffee????

  9. Mike says:

    I still don’t know what or where the “loop” is. Sorry.

  10. Yannick says:

    Sry, I don´t rly get it…
    In which loop exactly do i have to paste the code?

    Maybe it´s just me being brain-afk, sry for that.

    • Editorial Staff says:

      In the loop where you want to display thumbnails with captions. This could be your single.php file, or any other files.

  11. Dejan says:

    Thank you for this!!!

  12. Jhon Edison Bueno Martinez says:

    Thanks a lot, I have been looking for this and this is the best and simple explanation of how to add the image caption for featured images.


  13. Editorial Staff says:
  14. tonilehtimaki87 says:

    Short neat and to the point. Only critic goes for not providing example output for the short article. For other readers: Remember to read the related posts!

  15. Gary says:

    How can I style the caption?
    It is rendering the caption line outside of the DIV class in the source code? What am I doing wrong.

    Thanks in advance,

    • Editorial Staff says:

      You can wrap the echo content in a div of its own.

      • t.diaz says:

        I have been banging my head against a wall for about 4 hours trying to figure out how to wrap the echo content in its own div. (PHP noob here).

        Can you give me an example of how it would look to wrap the div on that echo?

        • Editorial Staff says:

          Do it like this:

          echo ‘open div here’ . get_post(get_post_thumbnail_id())->post_excerpt . ‘close div here’;

  16. karen says:

    This is great. Very helpful. Thank you so much! But it would really be helpful to show a screenshot of the result.

  17. Bronson says:

    This little gem comes in handy when wanting to spruce up most of the free themes out there… nice, quick and easy.

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.