Create a custom Sidebar in DWB
<?php
// Do NOT include the opening php tag
// Registering new sidebar
genesis_register_sidebar( array(
'id' => 'contact-sidebar',
'name' => __( 'Contact Page Sidebar'),
'description' => __( 'This is the contact page sidebar section.' ),
) );
// Registering a second custom sidebar
genesis_register_sidebar( array(
'id' => 'whatever',
'name' => __( 'Another Page Sidebar'),
'description' => __( 'This is another page sidebar section.' ),
) );
// Only add these custom sidebars when a page has a fitting label
add_action( 'get_header', 'siga_genesis_sidebars' );
function siga_genesis_sidebars() {
// Some conditionals to remove primary sidebar on pages with labels and add custom sidebars
if ( dynamik_has_label('contact-sidebar') || dynamik_has_label('whatever') ) {
remove_action( 'genesis_sidebar', 'genesis_do_sidebar' );
add_action( 'genesis_sidebar', 'siga_do_sidebar' );
// Force a layout if you want to
// add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_content_sidebar' );
}
}
/* --- Now set the custom sidebars ---*/
function siga_do_sidebar() {
// If a page has the label contact-sidebar, add the Contact sidebar
if ( dynamik_has_label('contact-sidebar') ) {
genesis_widget_area( 'contact-sidebar' );
}
// If a page has the label whatever, add the whatever sidebar
elseif ( dynamik_has_label('whatever') ) {
genesis_widget_area( 'whatever' );
}
}
<?php
// Do NOT include the opening php tag
// Only have it show up when a page has a certain label (sample: Contact sidebar). Code goes to Dynamik Custom - Functions. You will have to create the label first: Go to Dynamik Custom - Labels, name it contact-sidebar, check the checkbox for the conditional and save
// Registering new sidebar
genesis_register_sidebar( array(
'id' => 'contact-sidebar',
'name' => __( 'Contact Page Sidebar'),
'description' => __( 'This is the contact page sidebar section.' ),
) );
// Only add this sidebar when a page has label contact-sidebar
add_action('get_header','siga_custom_contact_sidebar');
function siga_custom_contact_sidebar() {
if ( dynamik_has_label('contact-sidebar') ) {
remove_action( 'genesis_sidebar', 'genesis_do_sidebar' );
add_action( 'genesis_sidebar', 'siga_do_contact_sidebar' );
}
}
function siga_do_contact_sidebar() {
genesis_widget_area( 'contact-sidebar' );
}