How To Add Caption To Featured Image of Your Blog Posts?

add caption to featured image

You may have seen many WordPress themes which get featured image caption to display under them. Do you know how to add caption to featured image?

Do you want to display it with the thumbnail of your blog posts? If you don’t know then let me tell you that a caption is an information about the image.

You can even add the caption with the images of your blog posts. In this tutorial, you will learn how to add caption to featured image with proper WordPress hooks.

Add Caption To featured Image Using GET_POST_THUMBNAIL_ID Function.

Before you jump into that, you should know how to add featured image support in a WordPress theme. I mean how would you show the caption if you won’t have the thumbnail?

NOTE:- WordPress considers each thumbnail as a post which can include the caption, title, alt tag, etc.

For the thumbnail post, the title would be the title of the image, the excerpt would be the caption and the content would be the description.

In the index.php file or in any file where you are showing the thumbnails, you can use this code.

<?php the_post_thumbnail();

echo get_post( get_post_thimbnail_id()) -> post_excerpt; ?>

This code will add caption to featured image.

You can design it according to the layout of your theme. You can display it below the thumbnail or anywhere you want.

You can add this code in a division tag so that you can easily set the position of the thumbnail.

<div class=”thumbnails”>

  <?php the_post_thumbnail();

  echo get_post( get_post_thimbnail_id()) -> post_excerpt; ?>


There are many ways to code the code thing. If you have a little bit of knowledge about PHP then you can create a variable first and then call it in the next line.

But here, I have provided the simplest code which can help you to get featured image caption.

I Hope You Can Add caption To Featured Image of Your Theme?

WordPress has many interesting features. You just have to use the right code. For a better design, you can add caption to feature image.

The position of the caption can be handled by the designing languages. You can do it your own. Though the code is shown above but still, if you face any problem, feel free to ask.

by Ravi Chahar

A WordPress Professional and the LinkedIn Influencer. A coder by passion and a blogger by choice. WordPress theme development is his forte. He is your WordPress guy who will teach you how to solve WordPress errors, WordPress security issues, design issues and what not.

Get Free Updates Into Your Inbox

Learn Everything Just Like I Did



  1. Hi,

    Yet another awesome tutorial to set caption for a post and I was looking for this tutorial as I was using some plugin for it.


  2. Hello Ravi Sir.
    It is a very precisely written tutorial. By the way thanks for sharing. I wanted to say that Adding the caption in post thumbnail i.e featured image also helps in maintaining the good SEO and keyword density. It also help in discovering the images on Google search using the alternative text option.
    Thanks again.

    Have a great day.

    1. Hey Prakhar,

      You can use the caption to add some more value to the featured images. There are many WordPress themes consist this feature. You can even edit your theme files to do the same.
      Of course, the SEO factor gets boost up with the caption. Google show the best images with the alt tags and captions in the search results.

      Thanks for stopping by.
      Enjoy your day.

  3. Indeed nice article and i must try this for my blog and soon get back to you if i will face any kind of problem

Leave a Reply

Your email address will not be published. Required fields are marked *