Jean is an Internet and Multimedia specialist with a keen interest in music, technology, business, sports and psychology.
Jean Galea
Internet Consultant in Malta
Jean Galea: entrepreneur and internet specialist. Holding an M.Sc. in Multimedia & Internet Computing from Loughborough University, Jean specialises in web design and development, email marketing systems and general internet consultancy.
How to add multiple Sidebars to WordPress
First thing, open your theme’s functions.php (or create the file if it is not already there), then insert the following code:
<?php
if ( function_exists('register_sidebar') ) /* for compatibility with old WordPress versions */
register_sidebar('name=Left Side Bar');
register_sidebar('name=Right Side Bar');
?>
That creates two sidebars for us, one named ‘Left Side Bar’and the other named ‘Right Side Bar’.
Then create two other files:
- sidebar-left.php
- sidebar-right.php
In sidebar-left.php insert the following code:
<?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar(1) ) : ?>
<!-- Your sidebar contents here -->
<?php endif; ?>
In sidebar-right.php insert the following code:
<?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar(2) ) : ?>
<!-- Your sidebar contents here -->
<?php endif; ?>
Final step is to include the sidebars in your template, so locate your main template file and insert the following lines where you want the sidebars to appear
<?php include (TEMPLATEPATH . '/sidebar-left.php'); ?> <?php include (TEMPLATEPATH . '/sidebar-right.php'); ?>
NOTES
Instead of using ids you could also use text strings when calling the dynamic sidebars. So for example in sidebar-left.php we could have used the code:
<?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar('Left Side Bar') ) : ?>
<?php endif; ?>
This is mostly convenient when you have many sidebars and thus it would not be very intuitive to use their ids.
Also if you just wanted to have static sidebars with predefined content which cannot be changed, all you need to do is create the two sidebar files, then include them in the template as shown above. In this case there is no need to edit the functions.php file and to include the dynamic_sidebar code in the sidebar files.
For further reading about this topic check out the following links:
http://www.blogohblog.com/adding-extra-sidebar-to-your-wordpress-theme/
http://bloggingexperiment.com/archives/adding-sidebars-to-wordpress-themes.php
http://bloggingexperiment.com/archives/add-widgets-wordpress-themes.php
Related posts:
- WordPress: Include a different sidebar for certain pages
- Plugins to Add Multiple Columns on your WordPress Page
- The Ultimate WordPress Thumbnail Hack
- Create a Custom Page Template in WordPress
- Best WordPress Guestbook plugin
2 Responses to “How to add multiple Sidebars to WordPress”
Leave a Reply
Thank you for reading this blog. Please check back for new posts.


Hi,in my first visit here i got this worthy tutorial. I will use it for my wordpress blog. Thanks buddy.
Glad you found it useful