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)
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!
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: http://cmspioneer.com/designwall/question/how-do-i-display-captions-for-images-in-a-gallery-post-type/
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; ?>
The code does not work because the lines were among the code listed is not already displayed.
Hi,
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(''); ?>
</div>
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 -->
</div>
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 !
Perfect, works completely!
Thank you very much for your help.
Please login or Register to submit your answer