asked 10 years ago

When I include a “featured image” in a new post, I would like to include the photographer credits below the photograph, (i.e., John Doe, Associated Press)

3 Answers
answered 10 years ago

Hi Salt

To add caption to the featured image please follow my instruction here:

– Add Caption when set featured image

– Add following code to content.php – line 22 in Your site > wp-content > themes > your theme > content.php

 <?php echo get_post(get_post_thumbnail_id())->post_excerpt; ?>

Hope this helps!

Proto Tyyp
replied 10 years ago

How can I display the image caption ON the picture rather than below it.

The way i used it to be displayed in the gallery function as seen here:

Miguel Agawin
replied 10 years ago

If you need the caption displayed under the featured image in a post, place the above code in content-single.php in the div with the class entry-thumbnail.

post_excerpt; ?>
answered 10 years ago

The code does not work because the lines were among the code listed is not already displayed.

answered 10 years ago

To resolve this issue, you can open the content-single.php file. Find the line 17 to line 19.
Replace the following code:

<div class="entry-thumbnail">
     <?php the_post_thumbnail(''); ?>

With new code:

<div class="entry-thumbnail">
<?php the_post_thumbnail(''); ?> <!-- this displays the featured image -->
<?php echo get_post(get_post_thumbnail_id())->post_excerpt; ?> <!-- this is the above code to display the caption -->

Note: To add the caption to the feature image, you can use the following sample bellow.

<p class="caption">Your content </p>

– If you want to style for the caption section, you can add the following code to the style.css file:

.caption {

Hope this helps !

replied 10 years ago

Perfect, works completely!

Thank you very much for your help.

Powered by DW Question & Answer Pro