[Resolved] Customize category page

Home Forums Support [Resolved] Customize category page

Home Forums Support Customize category page

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #950796
    Roger

    Hi, I’m trying to figure out how to customize the category page using the Header Element. I want to:

    – add a featured image to each post category
    – create a header element for the category page which uses the featured image with the category title and description for the page-hero

    Would be grateful for help on how to achieve this in GP. Thanks!

    #950832
    Leo
    Staff
    Customer Support

    Hi there,

    WordPress doesn’t allow featured images on archive/category pages so you will need to create a header element for each category and use the custom image option.

    Using the {{post_title}} template tag would output the category name:
    https://docs.generatepress.com/article/header-element-template-tags/

    Then this should work for category description:
    https://generatepress.com/forums/topic/add-custom_field-description-in-category-header/#post-375162

    Let me know if this helps ๐Ÿ™‚

    #950872
    Roger

    Thanks Leo.

    When I add Tom’s function to create the shortcode into the child theme’s functions.php file it gives me a fatal error. Any ideas on what I need to correct?

    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();
    }
    
    #950882
    Leo
    Staff
    Customer Support

    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();
    }
    #950886
    Roger

    Perfect, thanks. All working fine.

    #950897
    Leo
    Staff
    Customer Support

    No problem ๐Ÿ™‚

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