Can’t replace the default sidebar with a custom sidebar on Custom Post Type in Genesis

I have this post and the response from David Chu to thank for enlightening me.

There is nothing patently ‘wrong’ with the way that I implemented this. The reason that it doesn’t work is because of the fact that I have both the Genesis Simple Sidebars plugin and the Genesis Woocommerce Connect plugin installed.

Both of these make use of different Action Hooks to display the sidebar.

For Simple Sidebards you need to use:

remove_action( 'genesis_sidebar', 'ss_do_sidebar' );

..and if you have Genesis Woocommerce connect installed you need to use:

remove_action( 'genesis_sidebar', 'gencwooc_ss_do_sidebar' );

So my code in functions.php now looks like this.

function bge_swap_sidebar() {
  if ( is_singular('reviews' ) || is_post_type_archive( 'reviews'  ) ) {
    remove_action( 'genesis_sidebar', 'gencwooc_ss_do_sidebar' );
    add_action( 'genesis_sidebar', 'reviews_sidebar' );
  }
}

function reviews_sidebar() {
    dynamic_sidebar( 'chefsrecipes' );
}
add_action( 'genesis_before_sidebar_widget_area', 'bge_swap_sidebar' );