Site logo

[Support request] Different Sidebar layout on each category

Home Forums Support [Support request] Different Sidebar layout on each category

Home Forums Support Different Sidebar layout on each category

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #2417941
    Robert

    I have two categories and I want to have a different sidebar layout for each.

    I found the code to do this but it doesn’t do anything:

    add_filter( 'generate_sidebar_layout', function( $layout ) {
        // If we are on a category, set the sidebar
        if ( is_category() ) {
            return 'no-sidebar';
        }
    
        // Or else, set the regular layout
        return $layout;
     } );

    I do have GP premium but not on the website that I need this change on. So I tried the code above on a free GP theme.

    Does the code above work with GP premium only?
    How can I update my current free theme to premium without losing my settings and modified files?

    #2417967
    Robert

    I managed to fix it on my own.

    Turns out the code works only with in_category instead of is_category.

    #2418048
    David
    Staff
    Customer Support

    Glad to hear you got it working.

    FYI:

    is_category() -> is for the category archives
    in_category() -> is for a single post in a specific category

    #2419163
    Robert

    I didn’t know that. Thank you 🙂

    #2419406
    David
    Staff
    Customer Support

    You’re welcome

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