Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@neilgee
Last active December 2, 2017 05:02
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save neilgee/4210a153a86e31f504ac to your computer and use it in GitHub Desktop.
Save neilgee/4210a153a86e31f504ac to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment