Title: register_sidebars
Published: April 25, 2014
Last modified: February 24, 2026

---

# register_sidebars( int $number = 1, array|string $args = array() )

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/register_sidebars/?output_format=md#description)
    - [See also](https://developer.wordpress.org/reference/functions/register_sidebars/?output_format=md#see-also)
 * [Parameters](https://developer.wordpress.org/reference/functions/register_sidebars/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/functions/register_sidebars/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/register_sidebars/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/register_sidebars/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/functions/register_sidebars/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/functions/register_sidebars/?output_format=md#wp--skip-link--target)

Creates multiple sidebars.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/register_sidebars/?output_format=md#description)󠁿

If you wanted to quickly create multiple sidebars for a theme or internally.
This
function will allow you to do so. If you don’t pass the ‘name’ and/or ‘id’ in `$
args`, then they will be built for you.

### 󠀁[See also](https://developer.wordpress.org/reference/functions/register_sidebars/?output_format=md#see-also)󠁿

 * [register_sidebar()](https://developer.wordpress.org/reference/functions/register_sidebar/):
   The second parameter is documented by [register_sidebar()](https://developer.wordpress.org/reference/functions/register_sidebar/)
   and is the same here.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/register_sidebars/?output_format=md#parameters)󠁿

 `$number`intoptional

Number of sidebars to create.

Default:`1`

`$args`array|stringoptional

Array or string of arguments for building a sidebar.

 * `id` string
 * The base string of the unique identifier for each sidebar. If provided, and multiple
   sidebars are being defined, the ID will have "-2" appended, and so on.
    Default`'
   sidebar-'` followed by the number the sidebar creation is currently at.
 * `name` string
 * The name or title for the sidebars displayed in the admin dashboard. If registering
   more than one sidebar, include `'%d'` in the string as a placeholder for the 
   uniquely assigned number for each sidebar.
    Default `'Sidebar'` for the first
   sidebar, otherwise ‘Sidebar %d’.

Default:`array()`

## 󠀁[Source](https://developer.wordpress.org/reference/functions/register_sidebars/?output_format=md#source)󠁿

    ```php
    function register_sidebars( $number = 1, $args = array() ) {
    	global $wp_registered_sidebars;
    	$number = (int) $number;

    	if ( is_string( $args ) ) {
    		parse_str( $args, $args );
    	}

    	for ( $i = 1; $i <= $number; $i++ ) {
    		$_args = $args;

    		if ( $number > 1 ) {
    			if ( isset( $args['name'] ) ) {
    				$_args['name'] = sprintf( $args['name'], $i );
    			} else {
    				/* translators: %d: Sidebar number. */
    				$_args['name'] = sprintf( __( 'Sidebar %d' ), $i );
    			}
    		} else {
    			$_args['name'] = isset( $args['name'] ) ? $args['name'] : __( 'Sidebar' );
    		}

    		/*
    		 * Custom specified ID's are suffixed if they exist already.
    		 * Automatically generated sidebar names need to be suffixed regardless starting at -0.
    		 */
    		if ( isset( $args['id'] ) ) {
    			$_args['id'] = $args['id'];
    			$n           = 2; // Start at -2 for conflicting custom IDs.
    			while ( is_registered_sidebar( $_args['id'] ) ) {
    				$_args['id'] = $args['id'] . '-' . $n++;
    			}
    		} else {
    			$n = count( $wp_registered_sidebars );
    			do {
    				$_args['id'] = 'sidebar-' . ++$n;
    			} while ( is_registered_sidebar( $_args['id'] ) );
    		}
    		register_sidebar( $_args );
    	}
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/widgets.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/widgets.php#L174)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/widgets.php#L174-L214)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/register_sidebars/?output_format=md#related)󠁿

| Uses | Description | 
| [is_registered_sidebar()](https://developer.wordpress.org/reference/functions/is_registered_sidebar/)`wp-includes/widgets.php` |

Checks if a sidebar is registered.

  | 
| [register_sidebar()](https://developer.wordpress.org/reference/functions/register_sidebar/)`wp-includes/widgets.php` |

Builds the definition for a single sidebar and returns the ID.

  | 
| [__()](https://developer.wordpress.org/reference/functions/__/)`wp-includes/l10n.php` |

Retrieves the translation of $text.

  |

[Show 1 more](https://developer.wordpress.org/reference/functions/register_sidebars/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/register_sidebars/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/register_sidebars/?output_format=md#changelog)󠁿

| Version | Description | 
| [2.2.0](https://developer.wordpress.org/reference/since/2.2.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/functions/register_sidebars/?output_format=md#user-contributed-notes)󠁿

 1.   [Skip to note 2 content](https://developer.wordpress.org/reference/functions/register_sidebars/?output_format=md#comment-content-641)
 2.    [Codex](https://profiles.wordpress.org/codex/)  [  11 years ago  ](https://developer.wordpress.org/reference/functions/register_sidebars/#comment-641)
 3.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fregister_sidebars%2F%23comment-641)
     Vote results for this note: 2[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fregister_sidebars%2F%23comment-641)
 4.  Examples
      This will register 1 sidebar named Sidebar:
 5.      ```php
         register_sidebars();
         ```
     
 6.  This will create 2 sidebars named “Foobar 1″ and “Foobar 2″:
 7.      ```php
         register_sidebars( 2, array( 'name' => 'Foobar %d' ) );
         ```
     
 8.  This will create 2 sidebars with the title wrapped in <h1> and </h1>
 9.      ```php
         register_sidebars( 2, array(
         	'before_title' => '<h1>',
         	'after_title'  => '</h1>'
         ) );
         ```
     
 10.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fregister_sidebars%2F%3Freplytocom%3D641%23feedback-editor-641)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fregister_sidebars%2F)
before being able to contribute a note or feedback.