Hello support team.
On my website, all posts are categorized as either Press or Thought Leadership. I do not use sidebars on the main blog page or category archive pages. However, I want each individual post page to have a sidebar. Specifically, I want posts that are categorized as Press to have one sidebar and posts that are categorized as Thought Leadership to have a different sidebar. Accordingly, I have created one sidebar called Press and another sidebar called Thought Leadership.
I tried simply assigning by taxonomy, but that didn’t work. As discussed elsewhere, I think that function was designed for the main blog and/or archive pages only.
So then I tried to follow the instructions found at this thread, whose author had a similar need, but I was not successful.
This is what I added to functions.php in my child theme:
/* assign sidebar to support articles */
add_filter( 'ups_sidebar', 'add_press_sidebar' );
function add_press_sidebar($sidebar){
if (is_category ('press') ){
return 'ups-sidebar-press';
} elseif (is_category( 'thought-leadership' )) {
return 'ups-sidebar-thought-leadership';
}
else {
return 'ups-sidebar-none';
}
return $sidebar;
}
The behavior I’m seeing is that the Thought Leadership sidebar shows up on posts of both categories.