Skip to content

Instantly share code, notes, and snippets.

@srikat
Last active January 3, 2016 05:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save srikat/8414387 to your computer and use it in GitHub Desktop.
Save srikat/8414387 to your computer and use it in GitHub Desktop.
Using different sidebars for different Pages/Posts using labels in Dynamik. http://sridharkatakam.com/applying-different-sidebars-different-pagesposts-using-labels-dynamik/
// Switch sidebars
add_action( 'get_header', 'change_genesis_sidebar' );
function change_genesis_sidebar() {
if ( dynamik_has_label('leads') || dynamik_has_label('prospects') || dynamik_has_label('customers') ) {
remove_action( 'genesis_sidebar', 'genesis_do_sidebar' );
add_action( 'genesis_sidebar', 'sk_do_sidebar' );
}
}
/**
* Set custom sidebar
*/
function sk_do_sidebar() {
if ( dynamik_has_label('leads') ) {
echo do_shortcode( '[leads_sidebar]' );
}
elseif ( dynamik_has_label('prospects') ) {
echo do_shortcode( '[prospects_sidebar]' );
}
elseif ( dynamik_has_label('customers') ) {
echo do_shortcode( '[customers_sidebar]' );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment