Blog Development Web Wordpress

How to Add a Caption to a Featured Image in WordPress

Caption to a Featured Image in WordPress

Featured images are essential for any post or page in WordPress. Adding a caption to a featured image can enhance the context of the post or provide important information. Here’s how to do it easily.

Step 1: Add Code to WordPress

file functions

By default, WordPress does not display the caption of featured images in the theme. To fix this, you need to make a small adjustment in your theme’s file.

  1. Access Your Theme Files: From your hosting, go to the «functions.php» file of your child theme and open it to edit.
  2. Add Code: Add the following code at the end of the «functions.php» file and save it.
code legend image

Step 2: Prepare the Featured Image

image legend feature

Ensure the featured image is ready and uploaded to the WordPress media library.

  1. Access your WordPress admin panel.
  2. Go to Media > Library .
  3. Upload or select an image, and fill in the “Caption” field.

Step 3: Add the Featured Image to Your Post

featured image
  1. Create or edit a post/page.
  2. In the editor, find the “Featured Image” option in the right sidebar and select your prepared image.

Modify the Design of a Caption in a Featured Image in WordPress

To include the caption within the featured image, you can add the following code to your custom CSS in your WordPress theme.

.wp-caption {
    position: relative;
.wp-caption img {
    display: block;
.wp-caption-text {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: #29ABE2; /* Fondo celeste */
    padding: 5px;
    text-align: center;
    box-sizing: border-box; /* Incluye el padding en el cálculo del ancho */
    color: #fff; /* Texto blanco */

Here I show you the before and after with the code for designing a caption on a featured image in WordPress.

Change design in caption featured image


Adding a caption to a featured image in WordPress can be simple with the right steps. This improves accessibility and provides valuable information to your readers. Try these steps to give your featured images the context they deserve!

Leave a Reply

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

The reCAPTCHA verification period has expired. Please reload the page.