Site logo

Archived topic

Enable featured image with element.

3 replies · Started by antoine on September 4, 2019

Viewing posts 1–4 of 4

Hello,

I have GP premium and element installed with a header.

I would like to have my featured image showing both in archive post and single post. Below title. And with legend.

I tried this code:

add_action( 'generate_after_entry_header', 'tu_add_featured_image' );
function tu_add_featured_image() {
if ( is_singular( 'post' ) && has_post_thumbnail() ) {
the_post_thumbnail();
}
}
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) && is_single() ){
echo '<span class="featured_caption">' . $get_description . '</span>';
}
}

Now the caption is here. But I would like it below the image and be able to adjust font and size.

Thank you for your help.

Hello

I have found and use 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) && is_single() ){
echo '<span class="featured_caption">' . $get_description . '</span>';
}
}

Along with CSS to change color and font size.

Thank you

Awesome - glad you found a solution

This archived topic is closed to new replies.