How to: WordPress Unregister sidebar child theme function

Creating child theme is saves a lot of time and energy and efforts, when you don’t have much time or don’t want to create a theme from scratch then building child theme is recommended.

I love experimenting and try different CSS and WordPress theme development frameworks to create WordPress child themes and themes from scratch. I have used Bones, HTML5black, Underscore, Foundation Zurb and Bootstrap framework to build WordPress themes.

For this blog a few days back when I created a child theme based on 2012. I registered some new sidebar widgets for my child theme. WordPress 2012 theme already have 3 widget areas and these widgets were available in my dashboard.

But I didn’t need those widget areas for my child theme, So I decided to remove deregister widgets. If you don’t want to use some widget’s areas from the parent theme, then you can deregister those widgets areas with a very simple function.

To make WordPress widget screen cleaner in WordPress dashboard I decided to remove extra widgets. Here is code to remove parent theme’s sidebar. In my case 2012 is a parent theme and 2012 uses sidebar-1, sidebar-2 and sidebar-3 to register Widget areas.

If you are using the different theme then you will have to change sidebar-1 with your theme’s widget name. You can find it in your parent theme’s functions.php file.

WordPress Unregister sidebar child theme function

add this code to your child theme’s functions.php file.

// Remove 2012 default sidebar widgets from admin area
// http://codex.wordpress.org/Function_Reference/unregister_sidebar</code>
function remove_some_widgets(){
// Unregister some of the TwentyTen sidebars
unregister_sidebar( 'sidebar-1' );
unregister_sidebar( 'sidebar-2' );
unregister_sidebar( 'sidebar-3' );
}
add_action( 'widgets_init', 'remove_some_widgets', 11 );

Additional resources

Source: http://codex.wordpress.org/Function_Reference/unregister_sidebar

Leave a Reply

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