Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
add_action( 'genesis_before_sidebar_widget_area', __NAMESPACE__ . '\\sidebar_switcher' );
/**
* Conditionally replace the sidebar.
*
* @since 1.0.0
*/
function sidebar_switcher() {
// Switch to a different sidebar for 'project_post_type' CPT.
if ( 'project_post_type' === get_post_type() && is_active_sidebar( 'project-post-type-sidebar' ) ) {
remove_action( 'genesis_sidebar', 'genesis_do_sidebar' );
add_action( 'genesis_sidebar', function(){
dynamic_sidebar( 'project-post-type-sidebar' );
});
}
}
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.