[Resolved] Image Caption/Description problem

Home Forums Support [Resolved] Image Caption/Description problem

Home Forums Support Image Caption/Description problem

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #612682
    Kaleem

    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.

    #612795
    David
    Staff
    Customer Support

    Hi there, this topic provides a PHP Snippet for adding the Caption below the featured image:

    https://generatepress.com/forums/topic/featured-image-caption/#post-598608

    Adding PHP: https://docs.generatepress.com/article/adding-php/

    #612836
    Kaleem

    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

    #612878
    Leo
    Staff
    Customer Support

    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>';
        }
    }
    #612994
    Kaleem

    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.

    #613024
    Leo
    Staff
    Customer Support

    The padding is consistent. The problem is that your featured image isn’t wide enough:
    http://www.screencast.com/t/aVhsGfF9uap7

    #613025
    Kaleem

    Oh ok. Thank you for your help.

    #613071
    Leo
    Staff
    Customer Support

    No problem ๐Ÿ™‚

    #613747
    Kaleem

    @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.

    #613752
    Leo
    Staff
    Customer Support
    #614067
    Kaleem

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

    #614477
    Leo
    Staff
    Customer Support

    Glad I could help ๐Ÿ™‚

    #823808
    Steve

    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

    #823811
    Leo
    Staff
    Customer Support

    Try this CSS:

    .featured_caption {
        text-align; center;
    }

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

    #823815
    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;
    }

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