Using WordPress ‘register_sidebars()’ PHP function

The register_sidebars() WordPress PHP function allows you to create multiple sidebars for a theme or internally.


register_sidebars($number, $args);


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


  • $number (int, optional): Number of sidebars to create. Default is 1.
  • $args (array|string, optional): 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 is ‘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 is ‘Sidebar’ for the first sidebar, otherwise ‘Sidebar %d’.

More information

See WordPress Developer Resources: register_sidebars


Register one sidebar

This example registers a single sidebar named ‘Sidebar’.


Register two sidebars with custom names

This example registers two sidebars named ‘Foobar 1’ and ‘Foobar 2’.

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

Register two sidebars with custom title HTML tags

This example registers two sidebars with the title wrapped in <h1> and </h1>.

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

Register three sidebars with custom IDs

This example registers three sidebars with custom IDs.

register_sidebars(3, array('id' => 'custom-sidebar-'));

Register four sidebars with custom IDs and names

This example registers four sidebars with custom IDs and names.

register_sidebars(4, array('id' => 'custom-', 'name' => 'My Sidebar %d'));