Archived topic
Blog Category description not showing
7 replies · Started by Dominic on June 3, 2020
Hi,
We want to write text on our blog post categories under the field description.
This text when entert is not showing on the front end of the category.
See what I mean: https://www.screencast.com/t/xeWte4m02
How can we fix this?
Thank you for your help
Kind regards,
Dominic
Hi there,
That's because a header element is being used.
I think this is the best solution:
https://docs.generatepress.com/article/header-element-template-tags/#custom_field-name
Hi Leo,
thanks for the feedback.
Not being a developer I have no idea what to do with the {{custom_field.name}}
How should I use this and where?
Thank you for your time and help.
Kind regards,
Dominic
Let's try this method.
Add this code:
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();
}
Using one of these methods:
https://docs.generatepress.com/article/adding-php/
Then add the shortcode:
[term_description]
To the header element.
Let me know if this helps :)
-Using the code I get an error in code snippets
https://www.screencast.com/t/GJyHWrAKhOQ
It's probably a syntax error but I don't know enough of PHP to fix it.
https://www.screencast.com/t/6Xmw8a64V0
I've added the short code to the Global Header element that also All Archives as location.
Thank you for your time and help
Hi there,
i update Leos code above.
thanks
this works :)
It only doesn't display where I want it
https://www.screencast.com/t/QNyeS23CT
Tried it as a hook in the "before main content" but then it just displays the actual shortcode.
How should I proceed?
thanks again for all the help
Make sure to check the Execute Shortcodes option in the Hook Element