Completely Disable Sidebars in WordPress


Sidebar is a theme feature introduced with WordPress Version 2.2. It’s basically a vertical column provided by a theme for displaying information other than the main content of the web page. Themes usually provide at least one sidebar at the left or right of the content. These sidebars usually contain widgets that an administrator of the site can customize. Apart from standard sidebars you can register more sidebars in WordPress as you require. But in this article we will see how to disable sidebars in WordPress completely.

One might ask, why do you even want to disable a sidebar. Simply do not register it in first place, if you are not planning to use it on your website. That’s good point but sometimes you might not have an option. These days users use a parent theme framework as a base and create a child theme for customizing their website. Using child theme has many benefits, first and best of all is easy theme updates without worrying about resetting your modifications on each update. For example, TwentyTen theme have four footer sidebars and there are very good changes that you might not be using them all on your website. But if you remove those sidebars from functions.php then they will come back once you update TwentyTen theme in future. The solution to this issue is to use a child theme and disable sidebars from child theme’s functions.php.

Here is the code snippet you can paste in your theme’s functions.php to completely disable sidebars in WordPress. Don’t forget to replace sidebar-id in following code.

// completely disable sidebars in wordpress
function wcs_disable_sidebar() {
    unregister_sidebar( 'sidebar-id' );
add_action( 'widgets_init', 'wcs_disable_sidebar', 11 );

Here is another example to disable sidebars from footer of TwentyTen theme that we mentioned earlier.

// disable sidebars in wordpress
function wcs_disable_twentyten_sidebars() {
    // unregister some of the TwentyTen sidebars
    unregister_sidebar( 'first-footer-widget-area' );
    unregister_sidebar( 'second-footer-widget-area' );
    unregister_sidebar( 'third-footer-widget-area' );
    unregister_sidebar( 'fourth-footer-widget-area' );
add_action( 'widgets_init', 'wcs_disable_twentyten_sidebars', 11 );

Leave a Reply

Random Post Selection ::

Recent Posts

Unlock Unlimited Downloads