I like to use a child-theme.
The parent functions.php
function starkers_widgets_init() {
// Area 1, located at the top of the sidebar.
register_sidebar( array(
'name' => __( 'Primary Widget Area', 'starkers' ),
'id' => 'primary-widget-area',
'description' => __( 'The primary widget area', 'starkers' ),
'before_widget' => '<li>',
'after_widget' => '</li>',
'before_title' => '<h3>',
'after_title' => '</h3>',
) );
// Area 2 ...
My child-theme functions.php
function xtreme_unregister_sidebar() {
unregister_sidebar('primary-widget-area');
}
add_action( 'childtheme_sidebars', 'xtreme_unregister_sidebar' );
But doesn´t work for.
Thanks
Check the code bellow, I think that should work.
The Title of this post is for unregistering widgets not really sidebars, though I am glad the user got what they were looking for. For those searching for how to unregister widgets using a child-theme where the widget was registered in the parent theme, you can do that with this:
Assuming the Parent Theme’s Widget is registered at the widgets_init hook, all you need to do is wrap your unregister_widget() call inside of a function, hook that function into widgets_init, and give your hook a higher priority number than the Parent Theme’s widgets_init-hooked function.
Assuming the Parent Theme hooks into widgets_init without giving a priority number, the function will default to 10. So, just give your hook call a priority of 11 or greater.
so something like this:
Source