Archived topic
How to display category description on category page (header merge active)?
7 replies · Started by Matt on September 6, 2021
Hi there, I have the same issue as described here: here
I have added a category description but it's not displaying because of a custom page hero. So I have created a custom page hero just for categories but would like to show the description underneath the posts, if possible?
Hi there,
if you want it displayed below the posts, then create a new Block Element, design the layout like you did for the hero.
To display the description, add a GP Dynamic Content Block, and from its options select Term Description.
NOTE: The GP Dynamic Block doesn't have style controls, but it will inherit any typography / color settings you add to the Container Block it sits inside of.
The Hook to display below post is the after_main_content
It worked the first time. Genius, thank you!! :)
Glad to be of help!
Wanted to come back to this to ask if it's possible to only have the category text on the first page, to avoid dupe content issues on /page/2/ /page/3/ etc ?
Hi Matt,
You can try this PHP snippet:
add_filter( 'generate_block_element_display', function( $display, $element_id ) {
if ( 100 === $element_id && is_paged() ) {
$display = false;
}
return $display;
}, 10, 2 );
Replace the 100 with your block element ID which can be found in the URL of the block element:
https://www.screencast.com/t/BkrLmjoVZ
Adding PHP: https://docs.generatepress.com/article/adding-php/
Let me know if this helps :)
Thanks Ying, where would I add that php snippet?
Edit: Added in functions.php on child theme, worked great thanks!
Great! Glad you figured it out :)