Genesis Simple Sidebar - Conditionally change cased on CPT
<?php
//do not copy the above opening php tag
/**
* Conditionally Change Sidebar in Genesis whilst using Simple Sidebars
*
* @package Genesis Simple Sidebar on Custom Post Type
* @author Neil Gee
* @link http://wpbeaches.com/set-sidebar-custom-post-type-genesis/
* @copyright (c) 2014, Neil Gee
*/
function themeprefix_remove_default_sidebar() {
if ( get_post_type() == 'listing' ) { //set CPT here
remove_action( 'genesis_sidebar', 'ss_do_sidebar' );
remove_action( 'genesis_sidebar', 'genesis_do_sidebar' );
add_action( 'genesis_sidebar', 'themeprefix_add_cpt_sidebar' );
}
}
//Alternative Sidebar
function themeprefix_add_cpt_sidebar() {
dynamic_sidebar( 'sidebar-listing' ); //add in the sidebar name
}
add_action( 'genesis_before_sidebar_widget_area', 'themeprefix_remove_default_sidebar' ); //sets the ball rolling