Register Multiple Sidebars in WordPress: the simplest way

Registering multiple sidebars for your WordPress blog/site allows you to use different widgets in different areas of your blog/site. In this example we will see how to register 2 sidebars and then use them in your template files.

In order to register your sidebars and then be able to access them from the menu Appearance → Widgets all you need to do is:

  1. Open your functions.php theme file (* create one if it doesn't exist)
  2. Copy and Paste the following code inside the  <php ?> tag:
    register_sidebars(2, array('name'=>'Sidebar %d'));
  3. Go to the menu Appearance → Widgets. Drag & drop the widgets you want from the available widgets to the Sidebar 1 and Sidebar 2 you have created.
  4. Depending on where you want the sidebar's widgets/content to appear open your corresponding theme file, for example your sidebar.php and copy and paste the following (*change the number to 2 if you want to display your second sidebar):
    <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Sidebar 1') ) : ?>
    <?php endif; ?>

Tags: , , ,

Author:

One Response to “Register Multiple Sidebars in WordPress: the simplest way”

  1. Blogging To The Bank says:

    I just wanted to say that I found your web site via Goolge and I am glad I did. Keep up the good work and I will make sure to bookmark you for when I have more free time away from the books. Thanks again!

Leave a Comment