create multiple sidebars in wordpress
When you develop a wordpress theme maybe you have to use two sidebars which to use them both at once or on different pages. I recently encountered with this problem and i thought that maybe there is someone else in the same situation.
Creating multiple sidebars in wordpress is a fairly easy process. We have to work just on functions.php file. Your default functions.php file should look like this:
<?php
if ( function_exists('register_sidebar') )
register_sidebar();
?>
To create two sidebars paste the following code on your functions.php file:
<?php
if ( function_exists('register_sidebar') )
register_sidebar(array('name'=>'sidebar1',
'before_widget' => '',
'after_widget' => '',
'before_title' => '<h4>',
'after_title' => '</h4>',
));
register_sidebar(array('name'=>'sidebar2',
'before_widget' => '',
'after_widget' => '',
'before_title' => '<h4>',
'after_title' => '</h4>',
));
?>
As you can see i’ve created two sidebars called sidebar1 and sidebar2. To use these sidebars paste on your php files the following code:
Sidebar1 code goes like this:
<?php if ( !function_exists('dynamic_sidebar')
|| !dynamic_sidebar('sidebar1') ) : ?>
<?php endif; ?>
Sidebar2 code goes like this:
<?php if ( !function_exists('dynamic_sidebar')
|| !dynamic_sidebar('sidebar2') ) : ?>
<?php endif; ?>
Hope you enjoy this.

Hi. I am Marian, the owner of WPCONCEPT. I am a freelancer web designer focused on web development and i am a big fan of wordpress.
I am from Transylvania, Romania and please excuse my grammar mistakes. I do my best to improve my english skills.
by eJohnny on 20 March 2010 - Permalink
this helped me a lot