WordPress: Add more than one sidebar

Posted: July 10th, 2009 | Author: | Filed under: Wordpress | 1 Comment »

In wordpress it is possible to create multiple ‘sidebars’ with widgets on custom places in your template. To register a new sidebar open functions.php in your template folder (or create one), add:

if ( function_exists('register_sidebar') )
    register_sidebar(array(
        'name' => 'SIDEBARNAME',
        'before_widget' => '',
        'after_widget' => '',
        'before_title' => '',
        'after_title' => '',
    ));

Explaination of the array() :

‘name’ = name of your new sidebar
‘before_widget’ = Add a html element before you start your widget (eg. <div class=”widget”)
‘after_widget’ = close the element you started above
‘before_title’ = Add a html element before your widget title (eg. <h3>)
‘after_title’ = close the element you started above

Now al you have to do is add your new sidebar to your place in your template, add:

<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('SIDEBARNAME') ) : ?>

This is what shows when no widgets are added.

<?php endif; ?>

One Comment on “WordPress: Add more than one sidebar”

  1. 1 Hemanathagiribabu said at 11:04 am on April 21st, 2010:

    It is really very useful, this is what I am searching. Thanks for the posting