Instantly share code, notes, and snippets.

Embed
What would you like to do?
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