Skip to content

Instantly share code, notes, and snippets.

@renventura
Created November 6, 2014 18:08
Show Gist options
  • Save renventura/4c46e71cdec5180e005f to your computer and use it in GitHub Desktop.
Save renventura/4c46e71cdec5180e005f to your computer and use it in GitHub Desktop.
Replace the Primary Sidebar in Genesis with a custom sidebar for custom post types
<?php //* Mind this opening PHP tag
/**
* Register the sidebar for our CPT
* Goes in functions.php
*/
genesis_register_sidebar( array(
'id' => 'project-sidebar',
'name' => __( 'Project Sidebar', 'textdomain' ),
'description' => __( 'This sidebar is for displaying content in the side section of Projects only.', 'textdomain' ),
) );
/**
* Replace the primary sidebar with the CPT sidebar
* Goes in single-project.php or what your single CPT file is named
*/
remove_action( 'genesis_sidebar', 'genesis_do_sidebar' );
add_action( 'genesis_sidebar', 'rv_project_sidebar' );
function rv_project_sidebar() {
dynamic_sidebar( 'project-sidebar' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment