PureNews

PureNews is an amazingly sleek and powerful news theme with unlimited color variations.

View full feature list Check out the live demo Buy this theme today

How to add an extra sidebar

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!

John Leschinski is the creative director and founder of Leschinski Design. John's skill and talent is sought after by large and small companies and organizations, both local to the Rainy River district, London Ontario, and globaly. His experience and knowledge are also used in classrooms to groom the next generation of web developers and business seminars discussing e-commerce and the value of good design.

5 comments - Leave a reply
  • Posted by EL Locco on 17th Aug 2008

    Nice article, I will try to implement that soon. Thanks

  • Posted by Amaterashu on 17th Aug 2008

    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 :wink:

    thankss..

  • Posted by John Leschinski on 19th Aug 2008

    It's simple enough that I don't think it needs a plugin. Give it a try.

  • Posted by ladytomorrow on 5th Sep 2008

    Hi…. thanks so much for your help!

  • Posted by Som on 22nd Apr 2011

    Nice post . I have been searching for the info since long time .The result I used to get was not enough for me . Adding an extra sidebar simply simplify the requirement of space in WordPress theme .I use Twenty Theme in all of my directories .I hope this will be really helpful to me .Thanks for sharing the useful info here. Appreciate it.
    My recent post Websites Related to Category Beauty – Info Page 1