Disable wordpress sidebars without editing template

May 19, 2009 · Print This Article

What we’ll be showing you is two quick and easy ways to disable widget areas using your theme’s functions.php file.

Technically, what we’ll be doing is disabling the widgets, which is basically the same thing when you get right down to it.

This article assumes that your theme sets no default code if no widgets are shown. Otherwise, it is outside the scope of this tutorial.

Removing all widget areas

What we’ll be doing in this first function is disabling all widgets on the home page. First, open your theme’s functions.php file and input following php code:

add_filter( 'sidebars_widgets', 'disable_all_widgets' );
function disable_all_widgets( $sidebars_widgets ) {
if ( is_home() )
$sidebars_widgets = array( false );
return $sidebars_widgets;

This is a function that will remove widget areas from our home page. Well, you might have other pages, posts, archives, or whatever in mind that you want to disable widget areas on. In that case, you need to look up the appropriate WordPress conditional tag.

Removing a single widget area

Let’s suppose your theme has widgets in multiple places. Let’s further suppose that you want to remove only the footer widget area on single posts. This will be basically the same thing as above, but you need to know the ID of the widget area. This will be something you’ll either have to find in your theme’s code or ask your theme author about.

For the sake of this tutorial, the ID of our footer widget area is simply footer. We’ll create a new function for this as well. Add this to your theme’s functions.php file.

add_filter( 'sidebars_widgets', 'disable_footer_widgets' );
function disable_footer_widgets( $sidebars_widgets ) {
if ( is_single() )
$sidebars_widgets['footer'] = false;
return $sidebars_widgets;

Your choice for site templates and wordpress themes


3 Responses to “Disable wordpress sidebars without editing template”

  1. 8persap on September 6th, 2009 9:19 pm


    I’m very new to all this and I’m trying to remove sides bar on everything but the blog page.

    Please could let me know where in the function.php file this code…

    …should go? I’ve tried putting it at the top of the page but the side bars are still there. I’ve also tried the above code with ‘is_page()’ instead of ‘is_home()’ but still not joy.

    Any idea what I might be doing wrong??


  2. Live on September 8th, 2009 4:09 am

    In your wordpress theme’s directory(wp-content/themes/yourtheme), you can find functions.php and add code to the end of functions.php.

  3. Das Link-Widget auf der Startseite deaktivieren » realloc's asylum on July 17th, 2012 8:54 pm

    […] Auf der Suche nach der Lösung meines Problem mit WPML und den Widgets bin ich beispielsweise auf das  LinkTranslationWidget gestoßen. Aber meine spontane Idee, zwei Sidebars einzurichten, finde ich immer noch ziemlich in Ordnung und an sich war ja nur noch eine Lösung dafür zu finden, wie man das Link-Widget auf der Startseite entfernt, während es auf den anderen Seiten seine Aufgabe ganz normal erfüllen soll. Einen weiteren Anhaltspunkt für eine mögliche Lösung ergab sich beim Lesen von Disable wordpress sidebars without editing template. […]

Got something to say?

You must be logged in to post a comment.