Site logo

Archived topic

Strange header behaviour

13 replies · Started by Annamari on March 7, 2021

Viewing posts 1–14 of 14

I have a pages header element with this code (displaying the data on a hero image):

<h1>{{post_title}}</h1>
<div class="hero-desc">
	[page_hero_excerpt]
</div>

Everything's working fine on regular pages, but on shop and product category pages it's not okay, it doesn't display the excerpt but some random category description. (Eg. on the shop page this is the excerpt: "Letölthető online segédanyagok, útmutatók, e-book, munkafüzet otthoni feladatokhoz", and this is what's showing: https://kollarfranciska.hu/shop/)

What can I do to make it work?

Thanks!

Hi there,

I would recommend disabling that page hero on shop and category pages.

Then create a new page hero for them using this shortcode:
https://generatepress.com/forums/topic/add-custom_field-description-in-category-header/#post-375162

GPP 2.0 (currently in beta) would make it much easier to do this as well:
https://generatepress.com/introducing-the-gp-theme-builder/
https://docs.generatepress.com/article/dynamic-data/#term-meta

Let me know if this helps :)

Hi Leo, when I try to use that code, I get a fatal error-kinda message on the website (also Brackets shows that something's wrong, the curly bracket doesn't seem to be closed).

Can you try this instead?

add_shortcode( 'term_description', 'tu_term_description' );
function tu_term_description() {
    ob_start();
    echo term_description( get_queried_object()->term_id, 'category' );
    return ob_get_clean();
}

And even if I exclude the shop page from the general pages header and create a new header element which is set for the shop page, I still see that strange text...

This code doesn't give an error, thanks, Leo. The above problem is still there though...

Did you use this short code[term_description] instead in the new element?

Yes, this is my code:

<h1>{{post_title}}</h1>
<div class="hero-desc">
	[term_description]
</div>

To me it seems the exclusions aren't working...

I'd really love to solve this problem...

Hi there,

can you share a screenshot of your Elements list ?

In the Archive Header can you Exclude: Product Archive
And in the Shop Page Header change the location to: Product Archive.

You're a genious, David. I was becoming a bit of a mess. :)

Thanks for your help!

Glad to be of help!

This archived topic is closed to new replies.