[Resolved] Featured Image Captions

Home Forums Support [Resolved] Featured Image Captions

Home Forums Support Featured Image Captions

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #1304862
    Helge

    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.

    #1304898
    David
    Staff
    Customer Support

    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

    #1307950
    Helge

    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.

    #1308046
    Leo
    Staff
    Customer Support

    Try this CSS:

    .featured-caption {
        text-align: center;
    }

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

    #1308380
    Helge

    Thanks a lot. That worked.

    #1308850
    Leo
    Staff
    Customer Support

    No problem 🙂

    #1312527
    Helge

    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.

    #1312580
    David
    Staff
    Customer Support

    Try adding this CSS instead:

    .featured-caption {
        max-width: 1170px;
        margin-left: auto;
        margin-right: auto;
        text-align: center;
    }
    #1312732
    Helge

    Thanks a lot for the quick reply. That worked.

    #1313122
    David
    Staff
    Customer Support

    You’re welcome

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