Hi @GeorgiaG,
Sure, you can do that for your selected categories through code. And I guess you’re confused with already implemented code in your site. They are similar, the only difference is the condition so if you have to use and apply different sidebars then what you need are multiple conditions as well.
Example, this is the main block
add_filter( 'ups_sidebar', 'enforce_my_sidebar' );
function enforce_my_sidebar($sidebar){
/* your conditions and chosen sidebar here */
return $sidebar;
}
Let’s say we wish to display a different sidebar on posts, then resulting code will be
add_filter( 'ups_sidebar', 'enforce_my_sidebar' );
function enforce_my_sidebar($sidebar){
if ( is_singular ('post') ) return 'ups-sidebar-home';
return $sidebar;
}
or different sidebar on blog page
add_filter( 'ups_sidebar', 'enforce_my_sidebar' );
function enforce_my_sidebar($sidebar){
if ( is_home() ) return 'ups-sidebar-home';
return $sidebar;
}
And since it’s the same 'ups-sidebar-home'
, then we can just combine the two
add_filter( 'ups_sidebar', 'enforce_my_sidebar' );
function enforce_my_sidebar($sidebar){
if ( is_singular ('post') || is_home() ) return 'ups-sidebar-home';
return $sidebar;
}
The point is, you don’t need to add the same block of code, what you need is just to modify your existing one and apply your own conditions. Example, let’s add the category
add_filter( 'ups_sidebar', 'enforce_my_sidebar' );
function enforce_my_sidebar($sidebar){
if ( is_singular ('post') || is_home() || is_category('news') ) return 'ups-sidebar-home';
if ( is_category('video') || is_tax('portfolio-category', 'video') ) return 'ups-sidebar-video';
if ( is_tax('event-category') ) return 'ups-sidebar-booking';
return $sidebar;
}
In that sample, we’re not displaying two different sidebars for the post, blog, and news category, then another for blog and portfolio video category, and for event taxonomy.
There are many conditions, and only add one according to your preference.
Thanks!