[Resolved] Category Image in Header Element

Home Forums Support [Resolved] Category Image in Header Element

Home Forums Support Category Image in Header Element

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1782610
    Scott

    Hello Team –

    I am using the same plug-in as this topic and followed these instructions: https://generatepress.com/forums/topic/archive-page-featured-image/

    I can’t get the image to show within the hero header element that I have set up.

    My Hero Element for the Attribute page uses the following code from another topic on the board:

    <div class="hero-grid">
        <div class="hero-image">
           {{custom_field._thumbnail_id}}
        </div>
        <div class="hero-content">
            <h1>{{post_title}}</h1>
            {{custom_field.description}}
        </div>
    </div>

    I realize I need to change out {{custom_field._thumbnail_id}} to pull the correct image but don’t know what it needs to be changed to. A tag? Created a shortcode? Custom function?

    Thanks so much for your help!

    #1783359
    David
    Staff
    Customer Support

    Hi there,

    try adding this PHP Snippet to generate a Shortcode to output the image:

    add_shortcode('tax_image', function(){
        ob_start();
        if (function_exists('z_taxonomy_image')) { 
            z_taxonomy_image(); 
        } 
        return ob_get_clean();
    })

    Then you can use [tax_image] in your header element

    #1784005
    Scott

    Worked perfectly – thanks so much!

    #1784342
    David
    Staff
    Customer Support

    Glad to be of help!

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