Site logo

Archived topic

Category Image in Header Element

3 replies · Started by Scott on May 16, 2021

Viewing posts 1–4 of 4

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!

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

Worked perfectly - thanks so much!

Glad to be of help!

This archived topic is closed to new replies.