Archived topic
Featured Image Captions
9 replies · Started by Helge on May 28, 2020
I use the Dispatch Template. As a news magazine, I must provide a copyright notice and some words for each picture. I added the following code:
add_action( 'generate_before_content', 'db_featured_image_caption', 15 );
function db_featured_image_caption() {
$get_description = get_post(get_post_thumbnail_id())->post_excerpt;
if(!empty($get_description) && is_single() ){
echo '<span class="featured_caption">' . $get_description . '</span>';
}
}
I have tried almost everything that is suggested in the forum. Still the caption looks like it is part of the main text, not the picture. See the blog post in the attached URL.
Hi there,
to add the Copyright over the image - remove that function and follow the instructions i provide here:
https://generatepress.com/forums/topic/generatepress-dispatch-questions/#post-1093846
Hi David,
Many thanks for the quick answer! That looks much better. Unfortunately the caption is not aligned with the image. Left-aligned or centered would be great. Please advise.
Try this CSS:
.featured-caption {
text-align: center;
}
Adding CSS: https://docs.generatepress.com/article/adding-css/
Thanks a lot. That worked.
No problem :)
Hi Leo,
I am sorry, I have to re-open the topic. I've tried to left-align the caption. Unfortunately the following code did not help:
.featured-caption {
text-align: left;
}
The caption is now on the left side but not aligned with the corresponding picture. Please advise. Thank you very much.
Try adding this CSS instead:
.featured-caption {
max-width: 1170px;
margin-left: auto;
margin-right: auto;
text-align: center;
}
Thanks a lot for the quick reply. That worked.
You're welcome