Custom Sidebar for CPT Archive - Not showing

Hi everyone,

I have a custom post type called Projects and I want a custom sidebar for the Projects Index page. I have created the custom sidebar and i’ve added code into the functions.php file for my child theme to add the sidebar to the CPT but its still not working. There is a space on the right where it looks like the sidebar should appear but nothing is there.

Here is the code that I used:
// =============================================================================
// Assign sidebar to custom post archives
// =============================================================================
add_filter( ‘ups_sidebar’, ‘add_cpt_sidebar’ );
function add_cpt_sidebar($sidebar){
if ( is_post_type_archive(‘project’) && ! empty( $query->query[‘post_type’] == ‘project’ )) {
return ‘ups-sidebar-project-index’;
}
return $sidebar;
}
// =============================================================================

Hello @jamievilasini,

Thank you for the detailed post information.

Your sidebar did not display because the other sidebars “Who We Are” and “Motor Skills Training” were also selected to display in Projects post type. I have deselected the two sidebars and now your sidebar displays. Always keep in mind that only one sidebar should be assigned to display for your “Projects” post type.

Please check your site now.

1 Like

thanks so much @RueNel!

We’re glad that your issue is now fixed, @jamievilasini

1 Like

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