Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/register sidebars


Creates multiple Sidebars.

Registers one or more sidebars to be used in the current theme. Most themes have only one sidebar. For this reason, the number parameter is optional and defaults to one.

The args array parameter can contain a 'name' which will be prepended to the sidebar number if there is more than one sidebar. If no name is specified, 'Sidebar' is used.


 <?php register_sidebars$number$args ); ?> 

Default Usage

<?php $args = array(
	'name'          => __('Sidebar %d'),
        'id'            => 'sidebar',          
	'description'   => '',
	'class'         => '',
	'before_widget' => '<li id="%1$s" class="widget %2$s">',
	'after_widget'  => '</li>',
	'before_title'  => '<h2 class="widgettitle">',
	'after_title'   => '</h2>' ); ?>


(integer) (optional) Number of sidebars to create.
Default: 1
(string/array) (optional) Builds Sidebar based off of 'name' and 'id' values.
Default: None
  • name - Sidebar name.
  • id - Sidebar id. (Note: "%d" is added automatically to supplied 'id' value after the first; e.g., "Sidebar-1", "Sidebar-2", "Sidebar-3", etc.)
  • description - Text description of what/where the sidebar is. Shown on widget management screen. (Since 2.9) (default: empty)
  • class - CSS class name to assign to the widget HTML (default: empty).
  • before_widget - HTML to place before every widget.
  • after_widget - HTML to place after every widget.
  • before_title - HTML to place before every title.
  • after_title - HTML to place after every title.

The optional args parameter is an associative array that will be passed as a first argument to every active widget callback. (If a string is passed instead of an array, it will be passed through parse_str() to generate an associative array.) The basic use for these arguments is to pass theme-specific HTML tags to wrap the widget and its title.

Return Values



This will register 1 sidebar named Sidebar:


This will create 2 sidebars named “Foobar 1″ and “Foobar 2″:

register_sidebars(2, array('name'=>'Foobar %d'));

This will create 2 sidebars with <h1> and </h1> before and after the title:

register_sidebars(2, array('before_title'=>'<h1>','after_title'=>'</h1>'));


Since: 2.2.0

Source File

register_sidebars() is located in wp-includes/widgets.php.


Sidebars: is_active_sidebar(), is_dynamic_sidebar(), dynamic_sidebar(), register_sidebars(), register_sidebar(), unregister_sidebar(), wp_register_sidebar_widget(), wp_unregister_sidebar_widget(), wp_get_sidebars_widgets(), wp_set_sidebars_widgets()

See also index of Function Reference and index of Template Tags.