[Support request] Enable featured image with element.

Home Forums Support Enable featured image with element.

  • This topic has 3 replies, 2 voices, and was last updated 1 year ago by David.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1000616
    antoine

    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.

    #1000691
    David
    Staff
    Customer Support

    Hi there,

    how are you adding the caption?

    This topic here i provide a snippet for adding them in and this works on posts and archives:

    https://generatepress.com/forums/topic/cant-display-featured-image-captions/#post-854633

    #1000758
    antoine

    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

    #1001157
    David
    Staff
    Customer Support

    Awesome – glad you found a solution

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.