Creating Multiple Sidebar in Wordpress
Here you’ll know how to create multiple sidebar from scratch.
In this example, I created 2 sidebars. One from left and the other one from right.
The first thing you’ll need to do is to register the names of the sidebar (It’s like declaring a variable). This part is very important when you want your sidebar widgets to work.
I named the sidebars leftSidebar and rightSidebar.
<?php
if (function_exists('register_sidebar'))
{
register_sidebar(
array(
'name' => 'leftSidebar',
'before_widget' => '<li id="%1$s">',
'after_widget' => '</li>',
'before_title' => '<h2">',
'after_title' => '</h2>'
)
);
register_sidebar(
array(
'name' => 'rigtSidebar',
'before_widget' => '<li id="%1$s" class="holder">',
'after_widget' => '</li>',
'before_title' => '<h2 class="widgetTitle">',
'after_title' => '</h2>'
)
);
}
?>
Then create a page for these sidebars.
I created left.php for left sidebar. The codes below shows dynamic sidebar meaning, you can put as many widget as you want.
And the code “dynamic_sidebar(‘leftSidebar’)” is used to identify the sidebar. So all the widget you add on “leftSidebar” will show in left.php.
<ul>
<?php if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('leftSidebar')): ?>
<li>Please add some widgets here.</li>
<?php endif; ?>
</ul>
Repeat these codes to right.php and change “dynamic_sidebar(‘leftSidebar’)” to “dynamic_sidebar(rightSidebar’)”.
And to call these sidebars or to show these to the page, simply use this code
for left Sidebar
<?php include (TEMPLATEPATH . '/left.php'); ?>
And for right Sidebar
<?php include (TEMPLATEPATH . '/right.php'); ?>
And that’s all, you’re done!

