1

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?

  • You have unregister the parent sidebar with unregister_sidebar and register your own with the name you want. – Rubens Mariuzzo Aug 29 '13 at 19:35
  • thanks, I'm reading about it. I tried to do it just now but the bar still appears on admin>widgets – Lisandro Vaccaro Aug 29 '13 at 19:37
  • if you suggest it as an answer and complete it a bit, I'll accept. I simply unregistered and registered mine – Lisandro Vaccaro Aug 29 '13 at 20:03
3

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
| improve this answer | |
  • Nice solution, this is cleaner than unregistering and register it again. – Rubens Mariuzzo Aug 29 '13 at 20:24
  • Yes, excellent solution. It may result in an unexpected T_FUNCTION error though. Wordpress only requires PHP 5.2.4 but passing an anonymous function as a parameter requires 5.3. – epilektric Aug 29 '13 at 20:29
  • @epilektric I did this on purpose. – fuxia Aug 29 '13 at 20:34
  • @toscho Fair enough. – epilektric Aug 29 '13 at 20:56
0

Look functions.php file of twenty-twelve theme.

there is twentytwelve_widgets_init functions for registering sidebar.You can change name of sidebar from there.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.