Multiple Sidebars With WordPress Widgets
Written by Stefan Vervoort on September 2, 2008As I am working on a new WordPress theme I faced a problem with my sidebar and the widgets. This theme doesn’t run on one sidebar, but two. I didn’t know how to create more dynamic sidebars.

I asked Google, but there wasn’t a clear article that helped me along the way and I guess more people are struggling with this situation. After some research I finally found the solution on OrangeScale.
Widgets Core
To let WordPress Widgets preform on your blog, you should have the functions.php file ready with the right codes. This widget codes in the functions.php file usually looks like this:
PHP
<?php if ( function_exists('register_sidebar') ) register_sidebar(); ?>
To give your WordPress installation more sidebars, we have to extend these codes. We have to add more ‘options’ and we do that by adding more codes to the function and by given those seperated functions names like Sidebar 1 and Sidebar 2.
PHP
Sidebar 1
<?php if ( function_exists('register_sidebar') ) register_sidebar(array('name'=>'Sidebar 1', 'before_widget' => '<li id="%1$s" class="widget %2$s">', 'after_widget' => '</li>', 'before_title' => '<h2 class="widgettitle">', 'after_title' => '</h2>', ));
Sidebar 2
<?php if ( function_exists('register_sidebar') ) register_sidebar(array('name'=>'Sidebar 2', 'before_widget' => '<li id="%1$s" class="widget %2$s">', 'after_widget' => '</li>', 'before_title' => '<h2 class="widgettitle">', 'after_title' => '</h2>', ));
Name your Sidebar
To get more sidebars you need to name them and in our case, we will call them Sidebar 1, Sidebar 2 etc. as many as you would like. Here is how you do that:
PHP
You are able to change the values of before_widget, after_widget, before_title and after_title to whatever you like. These are just the example of what I use myself.
How to insert Multiple Widgets to your Theme
Open up the file you would like to have your widgets shown. When you already have one sidebar in place you will find the following codes:
PHP
<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?> <?php endif;?>
Now, find all the places you would like to add widgets. Insert Sidebar 1 where sidebar 1 should be located, and so on. Here we go:
PHP
Sidebar 1
<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Sidebar 1') ) : ?> <?php endif; ?>
Sidebar 2
<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Sidebar 2') ) : ?> <?php endif; ?>
Ready
After you’ve saved your file you will have two dynamic sidebars you are able to edit via WordPress Widgets. Of course, al lot more sidebars can be created and all the creativity that follows next, that’s up to you. Do you want to style your widgets now?


Thank you
Some people use a hierarchy method in the naming of the template files to achieve multiple WordPress sidebars, but in my opinion it is too cumbersome for most user’s needs. The method of multiple sidebars for WordPress that I use involves only a very simple PHP snippet added to the template to call the desired sidebar file depending on the area of the site that you are in.
@ Zacheos – I appreciate your thoughts on this one. I’ve read your article, and I think that solution is great as well.
The thing for me is, it doesn’t use widgets (which is possible to create of course), so for people using normal sidebars, your way is great.
Thanks for your thoughts and I like the site you have there!
[...] can this plugin do for you and how exactly do these codes look? Take a look around on DivitoDesign! I have been using this plugin since it’s early development. [...]
[...] Multiple Sidebars With WordPress Widgets Melhorar seu Theme [...]
[...] Read: “Multiple Sidebars With WordPress Widgets” [...]
[...] Multiple Sidebars With Wordpress Widgets [...]
it gave me error with }
This is perfect, thank you for your help!
Thanks for the tutorial on adding multiple widgetst to the side bar. I’ve been trying to do this exact thing with little success on a few of my sites. This has helped improve my wordpress themes greatly.
Thanks,
Jason
Thanks for including the example code. I can follow it and will see if I can implement it
[...] Widget ready themes [...]
I usually use 2 column themes to avoid that problem, but now that I know how I can use multiple column themes. Thanks!
Man I gotta learn php. I feel so behind the times.
This is a great tutorial. If you have any recommendations about plugins and widgets that will assist with getting high google rankings, I’d love to learn about them! Best regards.
I’m not sure if you got my last comment because there was a lot of clicking going on while I was typing. I’d love to learn more about how to use plugins and widgets to optimize a Wordpress blog for Google. Thanks!
Agreed, this is a great tutorial. I can tinker with my themes all day but if I have someone spell it out for me I can get them perfected so much faster.
I am finding new possibilities in wordpress everyday. It has really met all my expectations and more. Tutorials like this just make my day a whole lot easier. Thanks for a good post.
Awesome tip! Thanks!
This is a great read. I am starting to like wordpress more and more each day. So many possibilites.