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; ?> |

6 Comments »
Thank you for the most logical and easy-to-follow guide for adding an extra widget. A lot of sites complicate this process—I am glad you have done this in plain English.
Quick question: do I add the step 2 code (where I call the sidebar) in the page/main idex/etc… templates where it says:
Is that right?
Sorry, that should be “step 3.”
hey there!
great guide, agree with the previous commenter!
i have a question though, i’m not an expert at this but i have some knowledge;
what exactly does “Figure out where they should go and use the following code to activate each dynamic sidebar” mean?
i mean – how do i figure out “where they should go”? i want the two sidebars to appear next to each other and i have no idea of where to paste the code…
please help, i’ve been trying for hours now!
cheerio!
Coding explained simply and works for me.
Question if anyone can help, I am building a movie review database so need to enter different on the sidebar of each page. When i upload text into the widget, it appears on every movie page, how do i stop this and have the information appear only on the page I want?
Thank you very much, this will help me very much in the compilation of my new WordPress theme. Much appreciated!
Leave a comment