Genesis Tutorials

Tips, Tricks, and How-tos for the Genesis Theme Framework

  • The Genesis Developer’s HandbookVisual Hook Guide
  • code, settings & options oh my!Resources
    • Collection Of CodeSnippets
    • Under ConstructionGenesis Functions
    • Coming Soon…Utilizing Genesis SEO Options
  • Extend GenesisPlug-ins
    • Genesis Post Teasers
    • Genesis Favicon Uploader
  • Genesis Child ThemesThemes
  • What is genesistutorials.com?About
    • Genesis Tutorials Roadmap
You are here: Home / Snippets / Switch Genesis Default Sidebars with markup

Switch Genesis Default Sidebars with markup

April 9, 2011 by 4 Comments

This snippet is for Sidebar Sidebar Content Layout and will swap places of the wider and narrow sidebars.

add_action( 'genesis_before', 'gt_switch_sidebars' );
function gt_switch_sidebars() {
    $site_layout = genesis_site_layout();
    if ( $site_layout == 'sidebar-sidebar-content' ) {
        remove_action( 'genesis_after_content', 'genesis_get_sidebar' );
        remove_action( 'genesis_after_content_sidebar_wrap', 'genesis_get_sidebar_alt');
        add_action( 'genesis_after_content', 'genesis_get_sidebar_alt' );
        add_action( 'genesis_after_content_sidebar_wrap', 'genesis_get_sidebar');
   }
}

You may need to modify your child theme’s style.css in order to fit the swapped sidebars. For the default example child theme find #content-sidebar-wrap and change the width to 640px

*Bonus

Two snippets for the price of one 🙂

With a big change like this to the layout I would suggest registering a new layout to use for this code. Simply Register a new layout with:

 
genesis_register_layout( 'sidebarwide-sidebar-content', array(
    'label' => 'Wide Sidebar/Sidebar/Content',
    'img' => CHILD_URL . '/images/wssc.gif',
) );

With the new registered layout use sidebarwide-sidebar-content in place of sidebar-sidebar-content in the switch function.

Use the image above to just give it that extra touch ( place the image in your child theme’s images folder ).

Comments

  1. Grégoire Noyelle says

    June 4, 2011 at 8:00 am

    Hi Christopher
    Thanks for all you tuto.
    I try you trick, but it doesn’t works. Weird! And I use exactly the same code in my functions.php
    I try also the Bill Erikson’s one but same result.

    Reply
    • Grégoire Noyelle says

      June 4, 2011 at 8:06 am

      Sorry
      Now yours it works, but Bill’s one no. Really weird. I need to take a rest 🙁

      Reply
      • Christopher says

        June 4, 2011 at 11:21 am

        If you are running Genesis Simple Sidebars and using bills code there is a few things you need to change since Simple Sidebar actually removes the genesis_do_sidebar and genesis_do_sidebar_alt for in place of it’s own functions. The two below are what you’d want to remove.

        remove_action( 'genesis_sidebar', 'ss_do_sidebar' );
        remove_action( 'genesis_sidebar_alt', 'ss_do_sidebar_alt' );
        
        Reply
        • Grégoire Noyelle says

          June 5, 2011 at 11:14 am

          I do run Genesis Simple Sidebars. Good catch. Thanks Christopher. But like yours works well I keep it.

          Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Genesis Framework for WordPress

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Genesis Guide for Absolute Beginners

Click to download the Genesis Guide for Absolute Beginners

Follow me on Twitter

Follow @tweetsfromchris

Recent tutorials

Genesis 3.0.0 Removed Deprecated Functions

How to Add a Logo to the Header

Say Hello to the Genesis Visual Hook Guide v2.5

Genesis Tutorials • Built on the Genesis Theme Framework

Genesis Tutorials is not affiliated with StudioPress, and is maintained and operated by Christopher Cochran.

 

Loading Comments...