I’m using a child theme created from a twenty-twelve theme, the theme packs a number of sidebars one which is called “Main Sidebar”.

Is it possible to change it’s name to something else?

2 Answers
2

Hook into register_sidebar and change the name after the sidebar was registered.

Example:

add_action( 'register_sidebar', function( $sidebar )
{
    global $wp_registered_sidebars;

    if ( 'Main Sidebar' !== $sidebar[ 'name' ] )
        return;

    $id = $sidebar[ 'id' ];
    $sidebar[ 'name' ] = 'Master';

    $wp_registered_sidebars[ $id ] = $sidebar;
});

There is no need to unregister the original if you want to change just the name.

You can change other properties too:

  • description
  • class
  • before_widget, after_widget
  • before_title, after_title

Leave a Reply

Your email address will not be published. Required fields are marked *