How to add a Featured Image Caption in WordPress

My learnings about the featured image caption in WordPress core, using a dedicated plugin, or adding it with custom code to your theme.

You probably found this post because you use beautiful featured images from external authors and want to display their attribution in a caption or overlay. Let me show you how to accomplish this with code or easily using my featured image caption plugin.

Attachments in WordPress have a dedicated field for “Captions.” You can use this field to describe the image or add photo credits.

Unfortunately, while you can enter your featured image caption here, it is not guaranteed to appear on the frontend.

WordPress core comes with the get_the_post_thumbnail_caption() to retrieve the caption in PHP, but the theme must implement it. Though users requested it, there is no block or block setting for this yet.

I found the PHP function used in the TwentyTwenty theme, which does not yet use the Site Editor. In the current TwentyTwentyFour default theme, the caption does not show up.

So, if you relied on your theme to display the Featured Image Caption in WordPress, you might be locked into your theme, have to make PHP adjustments and lose future updates of your new theme, or use Image Source Control as your Featured Image Caption plugin.

Featured Image Caption Plugin

I built Image Source Control as an in-house plugin for multiple large publishing sites and eventually published it for use by other publishers with external images.

The plugin’s main feature is to display author attributions in three variants:

  • As an image caption below or an overlay above the image.
  • As a list below the page content.
  • As a global list of all images on a dedicated page.

One of the most beloved features is the overlay caption on featured images and images within the post content. However, the plugin also recognizes images in other positions to give visitors a concise experience with image captions.

As you would expect from an advanced featured image caption plugin, no coding is needed to get the caption working in most themes and even with page builders that use background images. It also comes with various styling options, like the position of the overlay or expanding on click or mouseover.

In addition to managing all captions in one place and displaying them in a consistent layout, Image Source Control also shows you missing image captions. This way, you won’t accidentally stumble into a copyright infringement, as I did over a decade ago, which led me to write the plugin.

Adding the Featured Image Caption feature with code

As mentioned above, WordPress core has the get_the_post_thumbnail_caption() function, which you can use to retrieve the caption in PHP. Ideally, you do this in the PHP template files of a child theme.

I’d probably search in the theme for the get_the_post_thumbnail function to identify the position where to add the custom code.

If you want to add a dedicated field to the featured image settings, try the code in this GitHub ticket. I haven’t done so myself and would use a maintained featured image caption plugin or wait for this feature to find its way into WordPress code.

Featured Image Captions and SEO

I have always wondered about the impact of image captions related to SEO. At some point, I picked up to do the following with images for SEO:

  • Use one of the keywords in the image file name before uploading it to WordPress.
  • Add a descriptive ALT text that, ideally, contains SEO-related text.

While I am also using image captions now, I am honestly unsure how relevant they are in indexing and ranking. Sure, I added the occasional keyword there, but I mostly tried to make them helpful to users.

Since Image Source Control uses image captions for author attributions, SEO optimizations, including the exact semantics of the code using a <figcaption> HTML tag shouldn’t matter. Do you disagree? Reach out and let me know.

Accessibility and Image Captions

I appreciate image captions that save me from understanding images, especially if their relation to the context isn’t obvious.

While researching to understand featured image captions better, I investigated their relevance for visually impaired people.

The ALT text, which you can enter in the media library and the image block options, seems the right place to describe the image for accessibility. It is widely supported and the default method for screen readers to look for image descriptions.

On the other hand, the image caption is the place to display descriptive text to all readers. It can go into more detail than ALT texts usually go and explain details for images, graphs, and other visual elements.

So, use both methods for the proper purpose, as I try to do on my websites.

Conclusion

While WordPress adds proper captions to images in the content of posts and pages, a featured image caption still only shows depending on the theme support. It might only be a matter of time until they get supported in the core.

Even then, they might be missing in other places. Check out my featured image caption plugin if you want a reliable way to include author attributions next to any image you can manage globally and cannot delete by accident.

How to add a caption to a featured image in WordPress?

Some older themes might support featured image captions out of the box. However, using a plugin like Image Source Control to manage and display image captions for all images is more reliable.

Portrait of Thomas Maier, founder and CEO of Image Source Control

Questions? Feedback? How can I help?

Reach out directly via the contact form.