Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Genesis Simple Sidebar - Conditionally change cased on CPT
//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
* @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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.