TechBattler

How to Display Caption Under Featured Image in WordPress

Featured image is one of the most important parts of a blog post. If you want to display captions under featured images, you came to the right place. Adding captions to featured images is so simple.

Displaying a caption under a featured image isn’t a fact for your SEO though some bloggers want to show captions under featured images. If you are one of them and looking to display featured image caption in WordPress, you won’t need to change the code or modify any hard part of your WordPress website. Some themes automatically show caption under the featured image. But, If your theme isn’t showing thumbnail caption, then don’t worry. I will share 2 methods to add captions to featured/thumbnail images. 

You can add featured image caption with a plugin or adding a simple code to your functions.php file.

Add Caption Under Featured Image in WordPress with Plugin ( Method 1)

For adding featured image caption through a plugin, you need to install the Featured Image Caption plugin. It’s a free plugin.

As you see in the screenshot, this plugin has a good number of installations. (4000+). Don’t worry about the “Last updated” options. This featured image caption plugin works fine in every theme.

However, After installing the theme, you will get a new featured image caption option in your sidebar.

add caption to featured image

Simply write down the caption “Caption Text” box. In addition, you can also add the source and source link of the picture in the “Source Attribution” field.

You can also choose where to display the caption in the plugin settings option.

Add Captions to Featured Image with a Code ( Method 2)

You don’t need to have any coding skills to go through with this process. You can simply display the featured image caption by adding this simple code to your theme’s functions.php file.

function the_post_thumbnail_caption() {
  global $post;


  $thumbnail_id    = get_post_thumbnail_id($post->ID);
  $thumbnail_image = get_posts(array('p' => $thumbnail_id, 'post_type' => 'attachment'));


  if ($thumbnail_image && isset($thumbnail_image[0])) {
    echo '<span>'.$thumbnail_image[0]->post_excerpt.'</span>';
  }
}

Add this code to your theme’s single.php or, index.php to display featured image caption

<?
        the_post_thumbnail_caption();
?> 

Now, you are all set up!

Conclusion

Displaying the caption in the featured image doesn’t change your Website traffic. Personally, I don’t use caption in my featured images. However, if you wish to add captions to featured images, the above 2 methods will help you do so.

If you face further problems for displaying the featured image caption on your WordPress website or these methods aren’t working for your current theme, then let me know in the comment section. I will surely reply.

Leave A Reply

Your email address will not be published.