Sidebars for categories not showing

There are no categories showing in the sidebar settings. All taxonomies is blank (empty).

I found this: Custom sidebars for category pages

add_filter( ‘ups_sidebar’, ‘custom_sidebar_on_pages’, 9999 );

function custom_sidebar_on_pages ( $default_sidebar ) {
if ( in_category(‘Audio’) ) {

return 'ups-sidebar-custom-sidebar';

}
elseif ( in_category(‘Video’) ) {

return 'ups-sidebar-news-events';

}
return $default_sidebar;
}

What I would like to know is how do I include multiple categories in the code?

For example, lets say I have these categories: Sound, Audio, Video and Playlist and I want a separate sidebar for each one. How do I achieve it by editing the above?

Hi @Bark201,

Thanks for reaching out!

In the code, you should change the category name to your category. Then to add multiple categories, please check the example code below.

add_filter( 'ups_sidebar', 'custom_sidebar_on_pages', 9999 );

function custom_sidebar_on_pages ( $default_sidebar ) {
  if ( in_category('Audio') ) {
    
    return 'ups-sidebar-audio';
} 
elseif ( in_category('Video') ) {

    return 'ups-sidebar-video';

  }

elseif ( in_category('Sounds') ) {

    return 'ups-sidebar-sounds';

  }
elseif ( in_category('Playlist') ) {

    return 'ups-sidebar-playlist';

  }
return $default_sidebar;
}

Please note that we cannot provide you with further custom codes. If you need some more complex coding, please consider signing up to One where we can provide some customization guidance.

Hope that helps.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.