Skip to content

Instantly share code, notes, and snippets.

@davidperezgar
Created September 18, 2016 21:12
Show Gist options
  • Save davidperezgar/06fe158f870b520c9979cda3f8e75da4 to your computer and use it in GitHub Desktop.
Save davidperezgar/06fe158f870b520c9979cda3f8e75da4 to your computer and use it in GitHub Desktop.
Genesis Custom Sidebar for Custom Post Type
// Register new sidebar
genesis_register_sidebar( array(
'id' =>id-sidebar’,
'name' => '',
'description' => '',
) );
add_action('get_header','cd_change_genesis_sidebar');
function cd_change_genesis_sidebar() {
if ( is_singular('jobs')) { // Check if we're on a single post for my CPT called "jobs"
remove_action( 'genesis_sidebar', 'genesis_do_sidebar' ); //remove the default genesis sidebar
add_action( 'genesis_sidebar', 'cd_do_sidebar' ); //add an action hook to call the function for my custom sidebar
}
}
//Function to output my custom sidebar
function cd_do_sidebar() {
dynamic_sidebar( 'job-single-sidebar' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment