I’m putting together my first WordPress theme which requires three dynamic sidebars (don’t ask!!). For some reason I can’t figure out how to add the other two dynamic sidebars.. Could you help me please?

Adding in multiple sidebars is fairly straightforward and you can create as many as you need.

Locate your functions.php file in your theme and add the following code:

1
2
3
4
5
6
7
8
9
10
<?php
     if(function_exists('register_sidebar'))
          register_sidebar(array(
          'name' => 'Sidebar One', // The sidebar name to register
          'before_widget' => '<div class="widget">',
          'after_widget' => '</div>',
          'before_title' => '<h3>',
          'after_title' => '</h3>',
     ));
?>

You should be customizing and styling these values to match your WordPress theme.

To add additional sidebars simply repeat the code only changing the ‘name’ value. I registered three sidebars in the example below:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
     // The first sidebar
     if(function_exists('register_sidebar'))
          register_sidebar(array(
          'name' => 'Sidebar One', // The sidebar name to register
          'before_widget' => '<div class="widget">',
          'after_widget' => '</div>',
          'before_title' => '<h3>',
          'after_title' => '</h3>',
     ));
     // The second sidebar
     if(function_exists('register_sidebar'))
          register_sidebar(array(
          'name' => 'Sidebar Two', // The sidebar name to register
          'before_widget' => '<div class="widget">',
          'after_widget' => '</div>',
          'before_title' => '<h3>',
          'after_title' => '</h3>',
     ));
     // The third sidebar
     if(function_exists('register_sidebar'))
          register_sidebar(array(
          'name' => 'Sidebar Three', // The sidebar name to register
          'before_widget' => '<div class="widget">',
          'after_widget' => '</div>',
          'before_title' => '<h3>',
          'after_title' => '</h3>',
     ));
?>

Finally you need to add each dynamic sidebar into your WordPress theme. Figure out where they should go and use the following code to activate each dynamic sidebar:

1
2
3
4
5
6
<?php
     if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('Sidebar One')) : // Each sidebar name
?>
<?php
     endif;
?>