Skip to content

Instantly share code, notes, and snippets.

@robneu
Last active December 17, 2015 06:19
Show Gist options
  • Save robneu/5564651 to your computer and use it in GitHub Desktop.
Save robneu/5564651 to your computer and use it in GitHub Desktop.
Switch Genesis Sidebars on All Dual Sidebar Layouts.
<?php
add_action( 'genesis_after_header', 'fatme_change_sidebar_order' );
/**
* Swap Primary and Secondary Sidebars on layouts with two sidebars
*
* @author Robert Neu
* @author Bill Erickson
* @link http://youneedfat.com/switch-genesis-sidebars/
*/
function fatme_change_sidebar_order() {
$site_layout = genesis_site_layout();
$dual_sidebar_layouts = array(
'sidebar-sidebar-content',
'sidebar-content-sidebar',
'content-sidebar-sidebar',
);
if ( in_array( $site_layout, $dual_sidebar_layouts ) ) {
// Remove the Primary Sidebar from the Primary Sidebar area.
remove_action( 'genesis_sidebar', 'genesis_do_sidebar' );
// Remove the Secondary Sidebar from the Secondary Sidebar area.
remove_action( 'genesis_sidebar_alt', 'genesis_do_sidebar_alt' );
// Place the Secondary Sidebar into the Primary Sidebar area.
add_action( 'genesis_sidebar', 'genesis_do_sidebar_alt' );
// Place the Primary Sidebar into the Secondary Sidebar area.
add_action( 'genesis_sidebar_alt', 'genesis_do_sidebar' );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment