Say your theme only has one sidebar.php and you want to have a different sidebar on your index then on your archives page. Adding extra sidebars is surprisingly easy and this is how to do it.
First we’ll create the sidebars. You can copy your current sidebar file and rename it to something like sidebar_two or sidebar_archives, almost anything you want really. If you decide to create it from scratch and want to maintain the widgets functionality of your theme be sure to include “<?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar(2) ) : else : ?> <?php endif; ?>“ in the file where you wish the widgets to appear.
Next we tell Wordpress you have two sidebars. Your theme may already have a file called functions.php, but if it does not go ahead and create that file with notepad and include the following bit of code “<?php if ( function_exists('register_sidebars') ) register_sidebars(2); ?>“ and put it in the theme folder. If you want to increase the number of sidebars just change the number in “register_sidebars(2);“ to the number of sidebars you desire.
If your theme already has a functions.php file, open it up and look for “register_sidebar“.If it exists add register_sidebars(2); at the end of it, or you can try replacing the whole thing with the code given previously.
So we have told Wordpress how many we want, and have created the required sidebar files, now we just have to place them into our template. Open the file you wish the specific template to appear and add “<?php include (TEMPLATEPATH . '/sidebar_two.php'); ?>“ or whatever you’ve named the file.
Now login to your admin, go over to your widget management tab, and you should see the sidebars listed there which you can now drag and drop the desired widgets into.
Voila!













EL Locco | August 17th, 2008 at 9:03 am #
Nice article, I will try to implement that soon. Thanks
Amaterashu | August 17th, 2008 at 10:29 am #
I’m bad at coding like that, can you make the plugin for it??
tell me if you can.. I’ll be waiting for it
thankss..
John Leschinski (Post Author) | August 19th, 2008 at 4:26 am #
It’s simple enough that I don’t think it needs a plugin. Give it a try.
ladytomorrow | September 6th, 2008 at 3:13 am #
Hi…. thanks so much for your help!