Archived topic
Strange beahavior on category archives with header lements
3 replies · Started by George on September 25, 2020
I've noticed something strange. I have entered descriptions for my post categories from the backend. Whenever I create a header element to be displayed in a certain post category archive and set the title tag on the header like this <h1>{{post_title}}</h1>, the category description is not displayed on the category archive. If I hardcode a text entry, though, like this, <h1>Events</h1>, I get the category description at the top of the category archive!
Any ideas??
Hi George,
The title and description are sort of linked together.
You can create a shortcode to display the category description within the header element:
https://generatepress.com/forums/topic/add-custom_field-description-in-category-header/#post-375162
Let me know if this helps :)
{{custom_field.description}} in the header element did the trick for me.
The title and description are sort of linked together.
Ok, I see. Entering {{post_title}} seems like it's taking into account the category description as well.
By the way Tom's code in the post you redirected me has an extra single quote in the echo statemnt on the 4th line. It needs to be:
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();
}
Then, the [term_description] shortcode would work. Maybe, Tom could modify it.
Thanks again, Leo!
No problem :)