Archived topic
Different Sidebar layout on each category
4 replies · Started by Robert on November 16, 2022
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?
I managed to fix it on my own.
Turns out the code works only with in_category instead of is_category.
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
I didn't know that. Thank you :)
You're welcome