Here’s how to replace the primary sidebar on a custom post type. First, register your sidebar. Next, use this code to swap the primary sidebar with the new one you just registered:
// Swap sidebars on CPT pages add_action('get_header','child_change_genesis_sidebar'); function child_change_genesis_sidebar() { if ( is_singular('post_type')) { // change 'post_type' to your CPT slug remove_action( 'genesis_sidebar', 'genesis_do_sidebar' ); //remove the default genesis sidebar add_action( 'genesis_sidebar', 'child_do_cpt_sidebar' ); //add an action hook to call the function for my custom sidebar } } // Output sidebar with the id 'sidebar-custom' function child_do_cpt_sidebar() { genesis_widget_area( 'sidebar-custom' ); }
If you want to display the sidebar on both the single post page and archive page for your custom post type, modify the if statement in child_change_genesis_sidebar()
function to include
if ( is_singular('post_type') || is_post_type_archive('post_type') ) {
Credit: Carrie Dils & Travis Smith from How to Use a Custom Sidebar on a Custom Post Type