[Resolved] Strange beahavior on category archives with header lements

Home Forums Support [Resolved] Strange beahavior on category archives with header lements

Home Forums Support Strange beahavior on category archives with header lements

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1459228
    George

    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??

    #1459341
    Leo
    Staff
    Customer Support

    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 ๐Ÿ™‚

    #1459660
    George

    {{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!

    #1460068
    Leo
    Staff
    Customer Support

    No problem ๐Ÿ™‚

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.