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)
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!
The code does not work because the lines were among the code listed is not already displayed.
To resolve this issue, you can open the content-single.php file. Find the line 17 to line 19.
Replace the following code:
<?php the_post_thumbnail(''); ?>
With new code:
<?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:
Hope this helps !
Please login or Register to submit your answer