Illustrated instructions have been made available here.

One of the more frequent questions we get is how to have different sidebars on the inside of a Wordpress blog than there are on the Homepage.  It is a pretty simple fix, but there isn't a ton of complete instruction available for it.  So we created this tutorial.

You probably already know about your sidebar.php file that came with Wordpress or the theme you've purchased.  That file controls your main sidebar.

Logically, you'd think all you need to do is make a secondary sidebar.  That's completely true.  Then  you just call it into the post template.

See Also:How many ads should I have on my site?

Here is how to have two separate sidebars without widget/dynamic functionality.  (Next, we will show you how to make your secondary sidebar widget ready so you can control it in your Widgets tool.)

For this lesson, we are going to assume that you want your post pages to have a different sidebar than your homepage.  The same instructions would apply if you wanted to have different sidebars on pages too.

STOP: Before continuing, make a backup copy of all your template files.  If you accidentally make a mistake, you can restore these files.

Basic Method:

  1. Find your sidebar.php file.
  2. Make a copy of it.  Name it sidebar-secondary.php.  Your second, third, forth, etc. sidebars all need to start with sidebar-NAMEHERE.php.  That's part of the naming convention in Wordpress.
  3. Make the content changes you need in secondary sidebar file.  This is where you make the secondary sidebar different.  Whatever it is you need to be different should go in this file.  Save sidebar-secondary.php and upload it to your server.
  4. Locate your single.php file.
  5. Look for a line near the end of the file that looks like this: <?php get_sidebar(); ?>
  6. Change it to <?php get_sidebar('secondary'); ?> (note, the 'secondary' part should match the name of the new sidebar-secondary.php file).  The single quote marks '  ' are required.
  7. Save your new single.php file and upload it.
  8. Done.

Enjoy. You've now made two separate sidebars.  You then told your single.php file (single posts) go fetch a different sidebar file than your index.php (homepage) does.  Your homepage will pull in the old sidebar.php file.  Your single posts will pull in the sidebar-secondary.php file. 

Note:

 In your sidebar-secondary.php file, you will want to remove the dynamic sidebar components.  Otherwise, your homepage widgets will also show up on your inside pages.  Look for a line like this: 

<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?>. 

Only remove that line of code from the file if you do not need the new sidebar to have dynamic widget functionality.  Otherwise, if you would like to wigetize this sidebar, proceed to the next lesson.

UPDATE:

Illustrated instructions have been made available here.

How to make your new sidebar Widget Ready or Dynamic:

We have to do two things.  1) Register your sidebars to your Wordpress backend knows you have two ready for widgets.  2) Tell each sidebar.php page which set of widgets to pull in.

Here we go:

1) Find your functions.php file.

2) Look for the register_sidebar section.  It will look something like this:

if ( function_exists('register_sidebar') ) register_sidebar(array( 'name' => 'Homepage Sidebar', 'id' => 'homepage_only', 'before_widget' => '<li id="%1$s" class="widget %2$s">', 'after_widget' => '</li>', 'before_title' => '<h2 class="widgettitle">', 'after_title' => '</h2>', ));

It may not contain all of the lines such as 'name' or 'id'.  It may not even exist at all.  In the next step, you will overwrite the old version.  If you don't have one, you will make one now. 3) Set one will control the homepage sidebar and should be setup to look like this:

if ( function_exists('register_sidebar') ) register_sidebar(array( 'name' => 'Homepage Sidebar', 'id' => 'homepage_only', 'before_widget' => '<li id="%1$s" class="widget %2$s">', 'after_widget' => '</li>', 'before_title' => '<h2 class="widgettitle">', 'after_title' => '</h2>', ));'name' => 'Homepage Sidebar', will refer simply to the name of the sidebar that shows up on the Widgets admin page drop down list.

'id' => 'homepage_only', is a unique ID just for that sidebar set.  We will add this ID to the sidebar templates later.

4) Next, make the second set for the inside pages:

if ( function_exists('register_sidebar') ) register_sidebar(array( 'name' => 'Inside Sidebar', 'id' => 'inside_only', 'before_widget' => '<li id="%1$s" class="widget %2$s">', 'after_widget' => '</li>', 'before_title' => '<h2 class="widgettitle">', 'after_title' => '</h2>', ));

5) STOP.  This is how a section inside your functions.php file should now look:

if ( function_exists('register_sidebar') ) register_sidebar(array( 'name' => 'Homepage Sidebar', 'id' => 'homepage_only', 'before_widget' => '<li id="%1$s" class="widget %2$s">', 'after_widget' => '</li>', 'before_title' => '<h2 class="widgettitle">', 'after_title' => '</h2>', )); if ( function_exists('register_sidebar') ) register_sidebar(array( 'name' => 'Inside Sidebar', 'id' => 'inside_only', 'before_widget' => '<li id="%1$s" class="widget %2$s">', 'after_widget' => '</li>', 'before_title' => '<h2 class="widgettitle">', 'after_title' => '</h2>', ));

6)  Continue.

7)  Locate your sidebar.php file.

8)  Locate the line that looks like this: <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?>

9)  Make it look like this: <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('homepage_only') ) : ?> You have now told your single.php file to go look specifically for the widgets assigned to the homepage_only function. 10) Locate your sidebar-secondary.php file.

11)  Locate the line that looks like this.  If none exists, don't worry. <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?>

12)  Make the line look like this.  If you do not have this line, simply add it in the possition where you want your dynamic widgets to appear. <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('inside_only') ) : ?>

13) Upload your newly changed functions.php, sidebar.php, and sidebar-secondary.php files to your server.

14) Earlier in the basic method, we already changed your single.php file to pull in the sidebar-secondary.php file.  So at this point, you are all done. You can now log into your Wordpress Admin and go to the widgets section.  You will now see a dropdown menu with your Homepage Sidebar and Inside Sidebar listed.  You can add widgets separately to each sidebar.  When you save, the changes will update on your site.

script type="text/javascript" src="http://forms.aweber.com/form/14/71940714.js">

This can be a little confusing.  All it takes is one little out of place punctuation mark to crash your whole site.  If you are comfortable with Wordpress, the previous intructions should get you by.  If it would be helpful to you to get some more details for each step including diagrams and images, fill out the form below.  We will send you the fully illustrated doccumentation immediately.

38 Comments