[Resolved] How to show Featured Image Caption

Home Forums Support [Resolved] How to show Featured Image Caption

Home Forums Support How to show Featured Image Caption

Viewing 15 posts - 1 through 15 (of 19 total)
  • Author
    Posts
  • #1506874
    Sagar

    Hi,
    I want to show featured image caption on all my blog posts. Captions are to be entered manually to give the attribution.

    Like this news website has given
    https://www.hindustantimes.com/it-s-viral/dad-s-complete-guide-to-baby-video-is-absolutely-hilarious-watch/story-opDXsEccg885ZFQXLnWooL.html

    The caption is: “The image shows a shot from the video. (Instagram/@howtodadnz)”

    Remember that, it will be different for all the blog posts.

    Thank you

    #1506893
    Leo
    Staff
    Customer Support

    Hi there,

    This snippet is the best for this:
    https://gist.github.com/diggeddy/5f7c3a4584a8beb51febc9c4f33d6c5c

    It needs to be added using one of these methods:
    Adding PHP: https://docs.generatepress.com/article/adding-php/

    Then you can just use the default Caption field from WordPress media library:
    https://www.screencast.com/t/asrNiTgXp8WB

    Let me know if this helps 🙂

    #1506901
    Sagar

    Thank you, Leo.
    But when I’m checking my AMP pages, the caption is showing two times. What’s wrong now?
    Check here: https://urbanhomecart.com/best-dishwasher-india/amp/

    the caption is ‘Dishwasher’

    #1507102
    Leo
    Staff
    Customer Support

    I’m really sure how AMP handles a WordPress option mod like this unfortunately.

    Would this CSS help?

    .wp-caption .wp-caption-text:not(.thumb-caption-text) {
        display: none;
    }

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

    #1507214
    Sagar

    Hi Leo,
    Why don’t you enable this as a default option for all the users? If anyone wants to use it they will use otherwise no.
    It’s just a small thing which much be enabled by default.

    #1507238
    Sagar

    It’s not working.

    http://prnt.sc/v8ek24

    I’m adding both the codes in customizer>additional CSS.

    #1507502
    David
    Staff
    Customer Support

    Which Amp plugin are you using ?

    #1507535
    Sagar

    I’m using AMP by Automattic
    https://wordpress.org/plugins/amp/

    #1507619
    David
    Staff
    Customer Support

    In the code Leo provided a link to here:

    Try changing this:

    } else {

    to

    } elseif( !is_amp_endpoint() ) {

    #1508355
    Sagar

    Why don’t you enable this as a default option for all the users? If anyone wants to use it they will use otherwise no.
    It’s just a small thing that must be enabled by default.
    Playing with codes is a scary thing for me for my website.

    #1508360
    Sagar

    } else {

    to

    } elseif( !is_amp_endpoint() ) {

    I did this. Now the featured image is not showing in the amp pages.

    #1508364
    Leo
    Staff
    Customer Support

    I’ll check with David to see if the code can be modified some more.

    Thanks for the suggestion.

    I’ll mention it to our team 🙂

    #1508373
    David
    Staff
    Customer Support

    Sorry about that – revert that change and instead try updating this line:

    if( $html == '' ) {

    to

    if( $html == '' || is_amp_endpoint() ) {

    #1508378
    Sagar

    Again, none of the featured images showing on any AMP page after this code.

    #1508393
    Sagar

    Sorry, I cleared the cache. Now it is working well. But please take my feedback to enable this featured image caption by default in the GP theme.
    As I’m really too far away from coding.

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