Site logo

Archived topic

Image Caption/Description problem

14 replies · Started by Kaleem on July 1, 2018

Viewing posts 1–15 of 15

Hi Sir, when I insert either the caption or description of the featured image, none appears with the image.
I want them appeared beneath the image. Thank you.

Hi, I added the snippet in child function, and the caption now shows, but it appears at the top of the title instead.

please visit the url

Try this instead:

add_action( 'generate_after_entry_header', 'db_featured_image_caption', 15 );
function db_featured_image_caption() {
    $get_description = get_post(get_post_thumbnail_id())->post_excerpt;
    if(!empty($get_description)){    
        echo '<span class="featured_caption">' . $get_description . '</span>';
    }
}

Great, it works. But it does not fit with the padding of the image. Is there any suggestion to make the caption follow the same padding of the image? Thanks a lot.

Oh ok. Thank you for your help.

No problem :)

@Leo, I just observed that the caption only works on Posts only, not Pages.
Any suggestion to make it display on both post and page? Thanks for your patience.

Wow that's great. Thank you so much. @Leo

Glad I could help :)

This seems to work for me, except for one thing, it's not centered on the photo. It's all the way to the left. How can I center it under the photo

Steve

Put in simple css and it does not seem to work. I have another entry could that be an issue?
Looks like this:

.page-header-image-single {
text-align: center;
}
.featured_caption {
text-align; center;
}

This archived topic is closed to new replies.