Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
CPT-specific sidebars
<?php
add_action( 'get_header', 'scl_cpt_switch_sidebar' );
function scl_cpt_switch_sidebar() {
remove_action( 'genesis_sidebar', 'genesis_do_sidebar' );
add_action( 'genesis_sidebar', 'scl_do_sidebar' );
}
function scl_do_sidebar() {
if ( is_page_template( 'page_whitepaper.php' ) ) {
dynamic_sidebar( 'whitepaper' );
return;
}
if ( function_exists( 'scl_find_post_type' ) )
$type = tees_find_post_type();
else
$type = get_query_var( 'post_type' );
if ( is_home() && !is_front_page() )
$type = 'post';
if ( isset( $type ) && !empty( $type ) && is_active_sidebar( $type ) && !in_array( $type, array( 'any', 'page', 'attachment' ) ) )
dynamic_sidebar( $type );
else
genesis_do_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.