PreviousPauseNext
Latest Free WordPress Themes | More Free Themes
Portfolio WordPress Theme
Portfolio Press

Dark Colored
Valid CSS/XHTML
Widgetized
Unique Layout
Styled Comments
Neat Code

Demo
Download
Latest Free WordPress Themes | More Free Themes
DailyPress WordPress Theme
DailyPress

Minimalistic Theme
125x125 Ad Space
Widgets Ready
Social Tagging
Tabbed Sidebar
XHTML Compliant

Demo
Download
Latest Free WordPress Themes | More Free Themes
Firebug WordPress Theme
Firebug

Colorful Theme
125x125 Ad Space
Widgets Ready
Social Tagging
Gravatar Ready
XHTML Compliant

Demo
Download
Latest Free WordPress Themes | More Free Themes
Gridblog WordPress Theme
Gridblog

Minimalistic Design
WP Gallery Ready
Gravatar Ready
Grid Based
Widget Ready
XHTML Compliant

Demo
Download
Latest Free WordPress Themes | More Free Themes
Blue Weed WordPress Theme
Blue Weed

WP 2.5 Gallery Compatible
Adsense Ready
Gravatar Ready
3-Columns
Widget Ready
Logo PSD

Demo
Download
Latest Free WordPress Themes | More Free Themes
AdsPress WordPress Theme
AdsPress

WP 2.5 Gallery Compatible
Adsense Ready
Gravatar Ready
2-Columns
Widget-Ready
Logo PSD

Demo
Download
Latest Free WordPress Themes | More Free Themes
Statement WordPress Theme
Statement

WP 2.5 Gallery Compatible
Quick Tabs
100% Width
3-Columns
Widget-Ready
Logo PSD

Demo
Download
Latest Free WordPress Themes | More Free Themes
Tutorials WordPress Theme
Tutorial Theme

Tutorials Feature
Thumbnails
Bright colors
3-Columns
Widget-Ready
XHTML Compliant

Demo
Download
Latest Free WordPress Themes | More Free Themes
Corptheme WordPress Theme
Corptheme

Four Flavors
Dropdown Menu
Separate Trackbacks
3-Columns
Widget-Ready
XHTML Compliant

Demo
Download
Latest Free WordPress Themes | More Free Themes
Chronicles WordPress Theme
Chronicles

Dark Brown
3-Columns
Widget-Ready
XHTML Compliant
Web 2.0

Demo
Download
Latest Free WordPress Themes | More Free Themes
Velocity WordPress Theme
Velocity

Trackbacks & Comments
3-Columns
Widget Ready
XHTML Compliant
Web 2.0

Demo
Download
Latest Free WordPress Themes | More Free Themes
Blue Lily Theme
Blue Lily

3-Column
Widget Ready
XHTML Compliant
Web 2.0
Rounded Edges

Demo
Download
Latest Free WordPress Themes | More Free Themes
Techicon Theme
Techicon

4-Column
Widget Ready
XHTML Compliant
Blue/White
Recent Boxes

Demo
Download
Latest Free WordPress Themes | More Free Themes
Brilliance Theme
Brilliance

3-Column
Widget Ready
XHTML Compliant
Black/White
Adsense Ready

Demo
Download
Latest Free WordPress Themes | More Free Themes
Identity Theme
Identity

3-Column
Widget Ready
XHTML Compliant
Black/White
Rounded Edges

Demo
Download
Latest Free WordPress Themes | More Free Themes
Xplosive Reloaded Theme
Xplosive Reloaded

3-Column
Widget Ready
XHTML Compliant
Multi-colored
CSS Style Switcher

Demo
Download
Latest Free WordPress Themes | More Free Themes
Limit Theme
Limit

3-Column
Widget Ready
XHTML Compliant
Blue/White
Rounded Edges

Demo
Download

Adding Extra Sidebar to your Wordpress Theme

Written by Jai on November 23, 2007 – 7:58 pm - 18,760 views

Oh!You like a Wordpress theme on the Internet but Oh!… What’s this?? The theme has only one sidebar! You need more than one and are on the verge of switching to some other theme with more sidebars. But wait!! Let me teach you how to add an extra sidebar or sidebars to your favorite theme. People who know PHP will find it easy to follow but even novices can easily do it using the code that I have provided in this tutorial. I am assuming that you already know HTML and a bit of CSS.

Working Hard!To begin the tutorial, extract your theme into a folder and open it to see all the files. If your theme has only one sidebar, then most probably you will NOT find a file called functions.php in your theme folder. In that case you will have to create this file yourself. Just open notepad or any other code editor to start a new file. Put this code into that file :-
<?php
if ( function_exists('register_sidebars') )
register_sidebars(2);
?>

Save the file as functions.php and put it in your theme folder. This piece of code actually tells Wordpress to register two sidebars for you (See register_sidebars(2) in the code). If your theme has more than one sidebar, you will find the functions.php file already present in your theme folder. You just have to edit the number to your requirement and save the file. You can increase this number if you want more sidebars and if your theme’s layout can accommodate it. Now, when you go to your Wordpress admin section and browse to the widgets under the menu item called presentation, you will see two sidebars listed there. You can drag your widget items into any of the sidebars.

Now comes the part where we actually build the sidebars. If your theme has only one sidebar, try to locate a file called sidebar.php in your theme folder. In this example, where we are trying to modify the theme for two sidebars, let’s rename sidebar.php to sidebar1.php and make a new blank file called sidebar2.php. Put this code into sidebar2.php and save the file :-
<div>
<ul>
<?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar(2) ) : else : ?>
<?php endif; ?>
</ul>
</div>

So, we have the two sidebars ready but they have not been placed in the index.php file yet. Both these sidebars need to be called from the index.php file in order to include them in your theme. Just open the index.php file from your theme folder and locate the code that calls your sidebar file (sidebar.php earlier). It should look something like :-

<?php include (TEMPLATEPATH . '/sidebar.php'); ?>

Edit this code and change the words sidebar.php to sidebar1.php.

Here you go!This takes care of the first sidebar. Now take a look at the index.php file carefully and find a suitable place to insert the second sidebar. This might involve modifying your layout or adding new divs. Once you find a suitable place, place the following code there :-

<?php include (TEMPLATEPATH . '/sidebar2.php'); ?>

Save the index.php file and now preview your theme. You will see all the widgets that you placed in both your sidebars appearing on your website. If you have not placed any widgets yet, you will not see any change. There might be alignment errors but you will have to fix them yourself. You can add more sidebars in a similar way to your Wordpress theme. I hope this tutorial helps some of you.

DIGG this tutorial!

If you enjoyed this post, make sure you subscribe to my RSS feed!


78 Responses to “Adding Extra Sidebar to your Wordpress Theme”

  1. I am dying to learn how to do coding and design a wordpress theme. I just need to find the time for it.

    Nice tutorial.


    Reply to this comment

  2. why not choose theme that already have 2 columns


    Reply to this comment

  3. @ayahshiva : Yes, you can apply the same procedure to a theme that has 2 columns. Just increase the number to 3 in the functions.php file. Then you will have to create three sidebar files and include them in your index.php file. This number also changes in the sidebar file code accordingly.


    Reply to this comment

  4. Nice tutorial.
    I should try this one.:-)


    Reply to this comment

  5. This 4 sidebar themes looks like hero! Great!


    Reply to this comment

  6. Thanks so much for this tutorial-I needed an easier version than the one I was using as reference(some folks just make things harder than they have to be)your method really helped me out.


    Reply to this comment

  7. @Restlessoul: Please post your technical question in the forums.


    Reply to this comment

  8. Your tutorial on how to add a sidebar literally did save me from switching from a theme I love! Thanks!
    I have just one question. How can I make it so the sidebar will be on the left side of my blog?


    Reply to this comment

  9. @Amr: You will have to use CSS for that.


    Reply to this comment

  10. i tried this tutorial with your Silver Light theme, but i get 2 sidebar with th esame content .. :(

    Where is my error ?
    Thanks


    Reply to this comment

  11. in the widgets section i got two sidebars that i created from your tutorial.. it’s great! Just trying to figure out more or less the same as “amr” is trying to figure.. how to get the bar over to the far right side instead of in the middle of the blog : )


    Reply to this comment

  12. great tutorial! thanks


    Reply to this comment

  13. I followed step by step…. in index.php there is no ” include sidebar” its somethig with “get sidebar()”.
    I’m not seeing the second sidebar :(


    Reply to this comment

  14. Thanks for article! Very easy to understand and I install additional sidebar to my blog in 5 minutes!


    Reply to this comment

  15. Thanks.I’ll optimize my wp to sell in ebay.


    Reply to this comment

  16. My functions.php looks like this:

    ”,
    ‘after_widget’ => ”,
    ‘before_title’ => ”,
    ‘after_title’ => ”,
    ));
    ?>

    How do I change this? Thanks.


    Reply to this comment

  17. Again:

    ”,
    ‘after_widget’ => ”,
    ‘before_title’ => ”,
    ‘after_title’ => ”,
    ));
    ?>


    Reply to this comment

  18. Sorry. I’ll post the first 2 lines again:
    <?php
    if ( function_exists(’register_sidebar’) )
    register_sidebar(array(


    Reply to this comment

  19. @EssEtch: After the line which says

    if (function_exists(’register_sidebar’))

    just add this line :-

    register_sidebars(2);

    where 2 is the no. of sidebars that you want to have in your wp theme.


    Reply to this comment

  20. i love this tutorial


    Reply to this comment

  21. Nice Article. I have a post on my blog about why having two sidebars can benefit the site in terms of ease of navigation and advetisement revenue.

    You can find the post here: http://bitfilm.net/2008/02/24/.....-sidebars/


    Reply to this comment

  22. Hi, Just following the post, which seemed easy enough. I am using one of your themes Kelabu and wanted to add a right side bar. All was good until the editing of the index.php. I cannot get the right side bar to appear. Can you help me any further?


    Reply to this comment

  23. i did whatever this tutorial said but i am getting this error

    Warning: array_merge() [function.array-merge]: Argument #2 is not an array in \wp-includes\widgets.php on line 53


    Reply to this comment

  24. if i give you theme url then can you please do this for me?


    Reply to this comment

  25. I am currently using the Silverlight-01 Theme. (Thank you very much!)

    The theme says it’s supposed to come with 2 sidebars. I tried dragging widgets into both
    Sidebar 1 and Sidebar 2 under >Presentation >Widgets. However, only the widgets from side Sidebar 2 show up (they show on the right hand side of the screen). How can I make the widgets from Sidebar 1 show up on the left hand side of the screen?

    Since I think the theme was meant to have 2 sidebars, I didn’t want to mess with the code and screw it up.

    However I did create the files sidebar1.php and sidebar2.php as the article describes.

    Thanks for the help.

    Chris


    Reply to this comment

  26. Thanks for the post, it was very usefull for me during “tuning” my theme


    Reply to this comment

  27. excellent tutorial, I needed this for my site to display RSS feeds from multiple places, thanks a million


    Reply to this comment

  28. I Love You, Thankyou Thankyou Thankyou.


    Reply to this comment

  29. This was exactly what I was looking for but could you perhaps elaborate or do a tutorial on the following for we novices brave enough to attempt this?

    “find a suitable place to insert the second sidebar. This might involve modifying your layout or adding new divs. Once you find a suitable place, place the following code there :-”

    Or even provide a link to where we can find this info?

    Cheers,
    DBR


    Reply to this comment

  30. tried this. messed up my wordpress site. Using wp 2.5. Just lettin’ people know. I’m not sure how successful this will be with recent versions of wp


    Reply to this comment

  31. should mention that my blog had NO sidebars to start with.


    Reply to this comment

  32. Hi, I am using the GreyLagoon theme and after going through tutorial step by step, I get this error message:

    Parse error: syntax error, unexpected ‘;’ in /home/oldwiza1/public_html/wp-content/themes/graylagoon-01/sidebar2.php on line 5

    I believe my error may be related to where I post this code:

    Can you help me?


    Reply to this comment

  33. I followed your steps exactly and am getting this:
    Warning: Cannot modify header information - headers already sent by (output started at /home/tablefou/public_html/momcooks/wp-content/themes/rockinruby-10/functions.php:6) in /home/tablefou/public_html/momcooks/wp-admin/theme-editor.php on line 60

    I don’t understand what adding a second sidebar has to do with the header. Any suggestions?


    Reply to this comment

  34. Thanks very usefull


    Reply to this comment

  35. IF you are getting a parse error..make sure you are inserting the right code in sidebar2.php, etc.

    Try this:


    Reply to this comment

  36. I noticed this post was published in Nov 2007. Does the trick work with new versions of WP? Or will things go wrong when I update it later?


    Reply to this comment

  37. @Matt: Yes, the modification will work with WP2.5 + version too.


    Reply to this comment

  38. Great mod - and all successfully changed although the problem I have now is that the widgets I use in the admin for sidebar 2 do not show on the sidebar 2.

    I simply get the same as sidebar one even though the admin says differently.

    Thanks


    Reply to this comment

  39. forget that - forgot to put a (2) in the second sidebar file. all is well now!

    Thanks a lot


    Reply to this comment

  40. Fantastic tutorial! Thanks for taking the time to do this!


    Reply to this comment

  41. Thank you for this tutorial.

    I was checking this for a client and you save my day. :D

    Rui


    Reply to this comment

  42. Hi Jai!

    I have been looking for a tutorial, however I cannot see the codes you posted in your post I can only see the first part of codes;

    “if ( function_exists(’register_sidebars’) )
    register_sidebars(2);
    ?>”

    But the rest are just blue boxes with nothing.
    Is it a problem on my end? I really need this tut and I tried to view the codes in both FF and IE.

    Noobatron..


    Reply to this comment

  43. @Noobtron : It was a problem with the way code in my posts was showing. Fixed now!


    Reply to this comment

  44. Allright, Thanks alot!
    and thanks for he tutorial!


    Reply to this comment

  45. thanks a lot.. this is really help full


    Reply to this comment

  46. just wanted to say a massive thank you for this article…

    it did require a few more detailed changes for my theme, but am delighted to report that after a root around my files, I manage to make the necessary changes.

    it looks lovely!


    Reply to this comment

  47. my sidebar functions starts like this
    if ( function_exists(’register_sidebar’) )
    {
    register_sidebar(array(
    ‘before_widget’ => ”,
    ‘after_widget’ => ”,
    ‘before_title’ => ”,
    ‘after_title’ => ”,
    ));
    }
    how to make my sidebar increase??thanks in advance.


    Reply to this comment

  48. @Chris:- I had that problem too but looks like that there is a drop down that you can switch between the 1 and 2nd column


    Reply to this comment

  49. Question: what about the header. I have a flash header and would like to know if the second sidebar will go under the header if i extend it or go beside it?


    Reply to this comment

  50. I dont get this tutorial :)

    I mean I see what you are getting at, but its really difficult to follow… Most of the time I cant find the code phrases you mention in my wordpress files :(


    Reply to this comment

  51. And yeah, modifying functions.php as you suggest causes an error.


    Reply to this comment

  52. Hi,

    and thanks for this turotial ! I havn’t applied it now, because I have question first.

    I have a theme with two sidebars at the right. Is it possible with your method a third sidebar, at the left corner?

    thanks in advance.


    Reply to this comment

  53. I’m working on a theme has a sidebar, but I can’t see how it is called to pages. There is no file like to be found anywhere.


    Reply to this comment

  54. Thank you guy for the tutorial , it’ll really work now in our radio estation.

    http://www.estaciondesconocida.cl

    Good guy ;)


    Reply to this comment

  55. Just like Dan Im not seeing on Idex.php. Instead I’m getting this: :(

    What should I do?


    Reply to this comment

  56. the code didnt show up. Im here again:

    i get this:


    Reply to this comment

  57. sorry I dont know whats going on I cant show the code properly. I get the pho get_sidebar thing


    Reply to this comment

  58. @ninku:- i assume you are using Journalist template and i’m also using this template and hard to follow this tutorial. Can u help us?


    Reply to this comment

  59. anyone use Flash news theme from woothemes ? I recently bought it a while ago and can not for the sakes of me , get any kind of sidebar running on it.

    It’s either you use their already pre-made sidebar or that’s it.

    After I tried to follow your directions it seems to work for half a second then disappears.


    Reply to this comment

  60. Big thanks from me too!

    Very useful - sorted out my third post-only sidebar.

    Cheers,

    Alex


    Reply to this comment

  61. packing sand grain by grain but i told my buddy i would finish this project for him. i hope i do. this tutorial helped me. thanks a bunch!


    Reply to this comment

  62. Hi jai,
    i am confuse where to put this code because my index.php file is like this


    Reply to this comment

  63. I’ve gotten everything to work, except the alignment, as you mentioned might be a problem.

    I can’t seem to get my new, 4th, column to sit next to the others, it keeps tucking itself below the 3rd column. I’ve tried extending the fixed width to fit it all, but i can’t get it to move. How do I fix this?

    any help would be greatly appreciated.


    Reply to this comment

  64. Great, Thanks for helping me.
    recently added one new sidebar at bottom :)


    Reply to this comment

  1. 14 Trackback(s)

  2. Adding Extra Sidebar to your Wordpress Theme — benway.net
  3. WordPress Template customisation | JazzyMoon
  4. ????? ?????? ? WP | ????????? ????
  5. Creeva’s World 2.0 » Web Wandering Dump
  6. ?????????? ?? ???????? ? ??????? ????????? ?????? ? WP | ?????? ?? ?????
  7. Creeva’s World 2.0 » How to add sidebar(s) to a Wordpress Theme | Blog Oh Blog
  8. Sea Sick | PLANET3RRY
  9. links for 2008-02-17 | jon bounds
  10. Making the web » The Benefits of Having Two Sidebars
  11. Peachy » Blog Archive » Länk: addnind av sidomenyer i Wordpress
  12. Why to Redesign your Blog? | ::..::Finding Your Own Good in One Place::..::
  13. The Benefits of Having Two Sidebars | Script Installer
  14. The Benefits of Having Two Sidebars | Making the Web
  15. eleen.com » Blog Archive » Three columns!

Post a Comment