[Resolved] Can't get the correct position for the Featured Image's caption

Home Forums Support [Resolved] Can't get the correct position for the Featured Image's caption

Home Forums Support Can't get the correct position for the Featured Image's caption

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1168626
    tbgr

    I’ve tried the various suggestions here for adding a caption to the Featured Image.

    I DID get it to work, but the caption is not UNDER the photo, as shown here:

    https://i.postimg.cc/Twr7MTtN/blair-caption.png

    Is there a way to have the caption directly under the photo?

    Thank you.

    #1168710
    Leo
    Staff
    Customer Support

    Hi there,

    Can you try this code instead:

    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 '<div class="featured_caption">' . $get_description . '</div>';
        }
    }

    Then this CSS:

    .featured_caption {
        text-align: center;
    }

    Adding CSS: https://docs.generatepress.com/article/adding-css/

    If this doesn’t work, we’d need to see the live site.

    Let me know ๐Ÿ™‚

    #1169048
    tbgr

    Thanks, Leo.

    That did the trick!

    #1169346
    Leo
    Staff
    Customer Support

    No problem ๐Ÿ™‚

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