Change a sidebar name?

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 Comment

tech