Adding captions to images in WordPress is a great way to add context to your content and make it more engaging. Captions can also help with SEO, as they provide additional information about the image that can be indexed by search engines. Fortunately, WordPress makes it easy to add captions to images. Here’s how:
Step 1: Upload Your Image
The first step is to upload your image to the WordPress Media Library. To do this, go to the “Media” tab in the WordPress dashboard and click “Add New”. From here, you can drag and drop your image into the uploader or click “Select Files” to browse for the image on your computer.
Step 2: Add the Caption
Once your image is uploaded, you can add a caption by clicking the “Edit” link next to the image. This will open the “Attachment Details” window, where you can enter your caption in the “Caption” field. When you’re done, click “Update” to save your changes.
Step 3: Insert the Image into Your Post
The next step is to insert the image into your post or page. To do this, go to the post or page where you want to add the image and click the “Add Media” button. This will open the WordPress Media Library, where you can select the image you want to insert. Once you’ve selected the image, click the “Insert into post” button.
Step 4: Preview Your Post
Finally, you can preview your post to make sure the caption is displaying correctly. To do this, click the “Preview” button in the WordPress post editor. This will open a preview of your post in a new window, where you can check that the caption is displaying correctly.
And that’s it! You now know how to add captions to images in WordPress. Captions are a great way to add context to your content and make it more engaging, so be sure to take advantage of them.
A picture may be worth 1,000 words, but just a sentence or two of text accompanying an image as a caption can often help drive a point home. Eyetracking studies have shown that website users often focus on compelling, relevant images and follow up by reading related text in adjacent captions.
But, if it’s your job to lay out images and captions on a web page, getting those elements to appear together consistently can be tricky. That’s why, in this guide, we’ll dig into how to add WordPress image captions.
How to Create WordPress Image Captions
The relationship between an image and its caption can begin as soon as you upload it to WordPress. There are two common approaches to getting images and captions together:
- Create captions in the WordPress Media Library.
- Create captions in the WordPress Editor “on the fly.”
We’ll take a look at both.
How To Create Image Captions Starting From the Media Library
Images you add to the Media Library usually end up in folders on your web server, while information about the images — including captions — are stored in the WordPress database.
To access the Media Library:
- Select Media > Library from the WordPress Dashboard.
- Click the Add New button to upload your target image.
Clicking on that image thumbnail brings up the Attachment Details window, where you can add your image caption.
Add your preferred text in the “Caption” field and, voilà, your image caption is added. You may be happy to know that, when editing image details here, WordPress automatically saves your work as you type.
You can also jump straight to a media upload by selecting Media > Add New from the WordPress Dashboard:
- Select (or drag and drop) the image to upload.
- Then click the Edit link beside the image thumbnail.
Clicking Edit opens the window that includes the image caption field:
That’s where you’ll be able to add your preferred caption. This time, though, you need to save your changes by scrolling down until you can click the Update button:
Now that you have captions stored with your images in the Media Library, you can easily feature them on a web page or blog post.
Let’s see how to do that using the block editor and the Classic Editor.
How To Add an Image With a Caption in the Block Editor
To add an image in the block editor:
- Click the [+] icon to display the blocks panel.
- Click the Image icon.
- Click the Media Library button.
- Then select your desired image.
The image and its caption are added to your layout.
How To Add an Image Caption in the Classic Editor
In the Classic Editor, you can add an image and its caption by clicking the Add Media button:
Once there, you’ll see the caption field on the right for you to edit. When happy with the text, click the Insert Into Post button.
That button will be labeled Insert Into Page if you are editing a WordPress page instead of a blog post.
Your image and caption will be displayed back in the editor.
How To Create Captions Directly From the WordPress Editor
The beauty of software is that there are usually multiple ways to get the same outcome. WordPress and image captions are no exception.
How To Upload an Image and Add a Caption in the Block Editor
In the block editor, click the [+] icon and choose the Image block option:
Next, click the Upload button.
Once you select (or drag and drop) your image, WordPress will place it within the editor. You’ll see the “Add caption” text below it.
To add your image caption, simply replace “Add Caption” with your own words.
Note that the caption you create is not saved to the Media Library when using this approach in the block editor.
How To Upload an Image and Add a Caption in the Classic Editor
If you’re using the Classic Editor, upload your image by clicking the Add Media button:
Next, click Upload Files in the Add Media window to select (or drag and drop) your image.
Your new image will be uploaded to the Media Library and displayed as selected with a checkmark. Add your image caption in the Caption field available in the Attachment Details panel.
After writing your caption, click the Insert Into Post (or Insert Into Page) button.
Your caption will be saved along with any other details to the Media Library and appear with the image back in the Classic Editor.
How To Edit an Existing WordPress Image Caption
What if you need to change or update captions already added to an image? You can do that in just a few steps. Here’s how.
How To Edit an Existing Caption in the WordPress Block Editor
The block editor treats a caption like any other text. To edit a caption, simply click on the text and make your changes.
Be aware that captions edited this way in the block editor are not saved with the image details in the Media Library.
How To Edit an Existing Caption in the WordPress Classic Editor
If you’re using the Classic Editor instead, click on the image to display the image-controls toolbar.
Next, click the pencil icon to edit the image details.
Enter your new text in the Caption field and then click the Update button. This will save your new image caption to the Media Library and get you back to the editor.
Tip: The Classic Editor also allows you to edit captions just like other text on a web page. Just remember that captions updated that way are not saved with the image details in the Media Library.
How To Add Captions in a WordPress Image Gallery
You can use similar methods to add captions to images in WordPress galleries.
Adding Captions to a WordPress Gallery Using the Block Editor
The block editor offers the Gallery block as an option after clicking the [+] icon:
In this scenario, we’re assuming this WordPress site is stocked with images and saved captions, so you’ll click the Media Library button.
In the Media Library, click the thumbnails of the images you want in the gallery. Checkmarks indicate your selections.
Click the Create A New Gallery button to continue.
As a final step before placing the gallery on blog posts/pages, the Edit Gallery dialog allows you to drag and drop images to change the order in which they will appear and to add or remove images from your selection.
When you are satisfied with the results, click the Insert Gallery button.
The Twenty Twenty WordPress theme used for this example superimposes the caption text on the associated image.
Adding Captions to a WordPress Gallery Using the Classic Editor
Here’s how to add an image gallery with captions using the WordPress Classic Editor.
Place your cursor where you’d like your gallery to be inserted, then:
- Click Add Media.
- Choose Create Gallery from the left-hand sidebar.
You can browse the images available for your gallery under the Media Library tab.
- Select the images you’d like to use in your gallery (indicated by checkmarks).
- Click Create a New Gallery.
Your selected images will appear in the Edit Gallery window. There, you can edit caption text for each one and, if you need to, you can change the order in which images are shown.
When you are happy with your gallery content and your image captions, click Insert Gallery.
Your images and captions will be displayed in the editor.
Note that captions can’t be edited in this view. To do so:
- Click anywhere on the gallery to highlight the group.
- Click the pencil icon.
You’ll return to the Edit Gallery dialog seen in the previous step, where you can again edit captions.
Changing the Appearance of WordPress Gallery Captions Using a Plugin
By default, WordPress uses just the Caption field stored in the Media Library when automatically applying image captions. However, the Gallery Image Captions (GIC) plugin provides a hook for custom PHP code that can build captions from any of the detail fields in the library, including custom fields.
GIC relies on WordPress shortcodes — specifically, the
[gallery] shortcode — to trigger the execution of the custom PHP you write. That code identifies which detail fields in the Media Library will be part of a caption and can even include HTML to help format the caption’s layout.
When you create a gallery using the Classic Editor, the
[gallery] shortcode is inserted behind the scenes. You can see that by clicking the Text tab to reveal the code:
At its simplest, the
[gallery] shortcode includes the ID numbers of the images selected for the display.
By default, the block editor immediately generates the HTML for a gallery when placing a group of images on a web page, but you can still choose the shortcode approach:
- Click the [+] icon within the editor.
This will bring up the available blocks panel.
- Begin typing “shortcode” in the search field.
- Click the [/] (shortcode) icon when it appears.
You can then enter the shortcode in the new block.
You must edit WordPress code within your theme to use the GIC plugin. You can add your custom PHP code for captions by editing your theme’s functions.php file. As that file can be replaced when a theme is updated, it’s best practice to create a child theme before making changes to key WordPress files. And, just to stay on the safe side of things, a quick backup never hurts.
An alternative approach is to use a plugin like Code Snippets, which allows you to insert PHP into your site’s code without editing functions.php.
Whether you are directly editing the functions.php file or taking advantage of a plugin like Code Snippets, your code will look something like this:
The key customization occurs on lines 17 and 18 above, where Title and Caption content from the Media Library is being inserted within some basic HTML markup to change the appearance of the captions.
In the Media Library, potential gallery images will require text in those fields:
With the GIC plugin installed along with the custom PHP code, the image captions in the gallery now look like this:
How To Add Image Captions to Featured Images
A featured image will, by default, have no caption in most WordPress themes.
For example, the image above is shown in the Media Library with a caption, but it appears without a caption when used as a featured image.
If you want a caption there, the FSM Custom Featured Image Caption plugin can help.
After the plugin is installed, its settings allow you to specify the stylesheet class you want to assign to your captions, or whether you will add custom CSS.
By default, the Custom Featured Image Caption plugin will display the caption stored with the image in the Media Library, but not within the editor.
The Custom Featured Image Caption plugin also modifies the Featured Image window within both the block editor and the Classic Editor so that it can accept an alternate caption, overriding any caption stored in the Media Library.
You can hide the caption and the featured image itself using the checkbox options at the bottom of the panel.
WordPress offers plenty of flexibility when it comes to adding and editing captions for individual images and images within galleries. And if the built-in options aren’t enough, you can use third-party plugins to extend its core functionality.
And here’s a tip: If your web projects are image-intensive, make sure you check out our guide on how to optimize images for web and performance.
Get all your applications, databases and WordPress sites online and under one roof. Our feature-packed, high-performance cloud platform includes:
- Easy setup and management in the MyKinsta dashboard
- 24/7 expert support
- The best Google Cloud Platform hardware and network, powered by Kubernetes for maximum scalability
- An enterprise-level Cloudflare integration for speed and security
- Global audience reach with up to 35 data centers and 275 PoPs worldwide
Get started with a free trial of our Application Hosting or Database Hosting. Explore our plans or talk to sales to find your best fit.