Sidebar for Custom Taxonomy Archives

Hi!

I’m trying to add a custom sidebar to a custom taxonomy page. I made a custom post type called “Projects” and I made a taxonomy that only shows in Projects called “Project Areas.” For each unique Project Area, I would like to show a different sidebar. For instance - “Motor Skills Training” is a Project Area. I would like to use a particular sidebar for the archive page for Motor Skills Training.

I realized that custom taxonomies do not appear on the Sidebar menu where you can check off the place where you would like the sidebar to show. I only see the categories/tags taxonomies related to the native Blog page.

I added this code to my functions.php to try to make this happen:

    add_filter( 'ups_sidebar', 'enforce_my_sidebar' );
    function enforce_my_sidebar($sidebar){

    if ( is_tax('motor-skills-training') ) return 'ups-sidebar-motor-skills-training';

    return $sidebar;
   }

Can you help me troubleshoot this? Thank you!!

Hi @jamievilasini,

Thanks for writing in! Regretfully, this particular customization request is outside the scope of our support as this is not related to an issue with the theme and instead has to do with your customization of it. As such, you will need to investigate this particular issue on your own or seek help from a developer should you not feel comfortable making these changes yourself.

Thank you for your understanding.

Hi @friech,

I understand that and appreciate your responding to my question. The thing is I saw an almost identical question asked in this forum, and it was answered, but its just that the answer didnt exactly fit my needs and that thread was closed already. As you can see, I’ve attempted with a piece of code but somehow its just not working. It would be wonderful if someone could help me out.

Ive reference this thread:


and:

Hello @jamievilasini,

You are using an incorrect condition. Instead of having;

if ( is_tax('motor-skills-training') ) {

You need this;

if ( is_tax('project-area', 'motor-skills-training') ) {

For your reference, please check this:

Your code may become this:

add_filter( 'ups_sidebar', 'enforce_my_sidebar' );
function enforce_my_sidebar($sidebar){

	if ( is_tax('project-area', 'motor-skills-training') ) {
		return 'ups-sidebar-motor-skills-training';	
	} 

	return $sidebar;
}

Hope this helps.

1 Like

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