WP Smith

Creating WordPress & Genesis Websites Since 2010

  • Home
  • About
  • Services
  • Blog
  • Contact

Mar 24 2011

How to Switch Primary Sidebar to Secondary Sidebar for a Specific Page in Genesis

For one of my sites, the person wanted to use two different sidebars: one for his store and another for his blog. The rest of the site was full-width layout. So we used the two sidebars: Primary (sidebar) and Secondary (sidebar-alt). So here's how to switch sidebars (without using Nathan's phenomenal plugin Simple Sidebars) using functions.php.

[php]//switch sidebars
add_action('get_header','change_genesis_sidebar');
function change_genesis_sidebar() {
$pages = array(181);

if ( is_page($pages)) {
remove_action( 'genesis_sidebar', 'genesis_do_sidebar' );
add_action( 'genesis_sidebar', 'genesis_do_sidebar_alt' );
}
} [/php]

This code can be easily adapted to be done based on category, archives, author, etc. See the conditional tags for more details.

Written by Travis Smith · Categorized: Genesis, Tutorials

StudioPress Premium WordPress Themes     WP Engine Managed WordPress Hosting

What can I do for you!?

Custom Development

We develop plugins by determining both business/functional and technical requirements, following WordPress development best practices, and using agile methodology to ensure you get the best solution.

Consulting

Have questions? Need a reliable developer to consult? Please contact us today!

Customized Theme

We can customize your theme or child theme, or create a child theme for you based on your needs while enhancing the performance of every individual attribute.

Customized Plugin

We can customize your plugins, extend plugins (e.g., Gravity Forms, Jetpack, Soliloquy) based on your needs ensuring security, performance, and positive business impact.

Contact Us

About Travis Smith

As a WordPress enthusiast, developer, and speaker, Travis writes about what he learns in WordPress trying to help other WordPress travelers, beginners and enthusiasts with tutorials, explanations, & demonstrations.

Comments

  1. Jenny says

    March 24, 2011 at 12:05 pm

    Travis,

    I think this function: add_action( ‘genesis_sidebar’, ‘genesis_do_sidebar_alt’ ); is the major part of the coding. I think alt is for secondary sidebar right? Thank you for this nice post.

    Reply
    • Travis Smith says

      March 24, 2011 at 12:46 pm

      add_action( ‘genesis_sidebar’, ‘genesis_do_sidebar_alt’ ); only adds the Secondary Sidebar (and yes alt stands for the Secondary Sidebar). However, you still need to remove the primary and apply any conditions if you want them. Otherwise you may want to consider forcing a particular layout if you just want to add the secondary sidebar on certain pages.

      Reply

Leave a Reply Cancel reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  • Twitter
  • Facebook
  • LinkedIn
  • Google+
  • RSS

Copyright © 2025 � WP Smith on Genesis on Genesis Framework � WordPress � Log in