Show different sidebars in single posts based on Category

I am trying to use the Unlimited Sidebars feature to show different sidebars based on which category they are in - the feature requires that we check things off individually, making it very difficult for a large amount of posts.

I saw a tip on another thread and put this in the theme functions:

function add_tax_sidebar($sidebar){
	if (is_category ('offshore')){
		return 'ups-sidebar-offshore';
		
	} elseif (is_category('taxation')){
		return 'ups-sidebar-taxation';
	} 
	else {
		return 'ups-sidebar-main';
	}
	return $sidebar;
}
add_filter( 'ups_sidebar', 'add_tax_sidebar' );

So from what it looks like, it should show the “offshore” sidebar for the offshore category, “taxation” sidebar for the “taxation” category, and a default “main” sidebar for everything else. The function doesn’t break the theme but it seems to just show whatever “else” sidebar is listed, so I know it’s half working…how can I get this function to work?

I found this http://www.laplacef.com/2014/05/20/how-to-add-custom-sidebars-for-each-category-in-wordpress/

There are some custom sidebar plugins that will allow you to define the sidebar per category

Found a plugin called “Content Aware Sidebars” that seems to work as soon as you delete any custom sidebars from the native sidebar manager!

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