[Resolved] Page Header Featured Image Template Tag

Home Forums Support [Resolved] Page Header Featured Image Template Tag

Home Forums Support Page Header Featured Image Template Tag

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #567099
    Chad

    Hi, is there a template tag for using the featured image within the HTML content section?

    Something like {{post_thumbnail}} or {{post_image}}…

    I need to use the featured image as an image in the content rather than just the background. I could create a custom field but would prefer to avoid that is possible.

    Thank you!

    #567101
    Chad

    Oh, wanted to add… I need it to use the featured image of the page the page header is being used on — not the featured image on the page header itself — hope that makes sense. πŸ™‚

    #567102
    Chad

    Doh, found it.

    {{custom_field._thumbnail_id}}

    πŸ™‚

    #567104
    Chad

    I guess one follow-up question.

    Do page header {{custom_field}} tags work with ACF?

    #567382
    Chad

    Nevermind, I found out it does.

    A thread all to myself! πŸ˜‰

    #567438
    Tom
    Lead Developer
    Lead Developer

    Glad you got it all working! This thread will likely be very helpful to others πŸ™‚

    Thanks!

    #569187
    Chad

    Hi Tom. Follow-up question.

    Is there a way to target specific image sizes with {{custom_field._thumbnail_id}}?

    Thanks!

    #569252
    Tom
    Lead Developer
    Lead Developer

    There is!

    Try this:

    add_filter( 'generate_page_header_thumbnail_id_size', 'tu_adjust_page_header_featured_image' );
    function tu_adjust_page_header_featured_image() {
        return 'full';
    }
    #1269837
    Vernon

    Hi Tom, I’m not a coder so beware!

    I follow everything up to why you provided the “add_filter” php??? code snippet, but where do I add this code? Do I use the Elements functionality? Or do I need to install the “Code Snippets” plugin?

    Just a nudge in the right direction and I’ll probably “get it.” Thanks!

    #1270118
    David
    Staff
    Customer Support

    Hi there,

    that code is PHP – this article explains the options:

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

    TLDR: Code Snippets is the method we recommend if you’re not using a Child Theme

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