39 Responses

  1. Stephen Cronin
    Stephen Cronin March 9, 2009 at 8:35 pm | | Reply

    Simple, but great!

    To be honest, I’d hack the theme files and create a mess. I’m really going to try to use functions.php more often now (and move some of my custom plugins into there as well). Thanks for showing the way…

  2. Eduardo Larequi
    Eduardo Larequi March 16, 2009 at 1:10 pm | | Reply

    Good work, Justin. For some weeks, I had been looking for an easy and understandable explanation of this technique (my skills in PHP are very limited) in order to apply it to my blog. I’ve just published an article with a demonstration: Desactivar la barra lateral sin tocar las plantillas de WordPress. Thank you very much.

  3. Paul
    Paul March 18, 2009 at 7:56 am | | Reply

    http://www.livexp.net/wordpress/remove-widget-areas-without-editing-wordpress-template.html

    Dear Justin

    Today I come across the article ( link above) that is exactly like yours in this post.
    So, this is just to let you know.

    I have been reading your blog for awhile and using your wptheme (hybrid) and
    It’s the greatest wptheme around. I admire the way you write code.
    I hope you keep up the good work and be more success in the future.

    Paul

  4. links for 2009-03-19 « On New Media March 19, 2009 at 3:06 am |
  5. The Frosty @WPCult
    The Frosty @WPCult June 23, 2009 at 3:10 pm | | Reply

    Wonder how I can disable just one widget on a certain page..

  6. smi1ey
    smi1ey July 21, 2009 at 12:44 pm | | Reply

    So I tried changing the “['footer']” part of the code to the name of the widget area I need to remove, and nothing happened. I have a suspicion that I need to change more than that in the code. Do I also need to change the “disable_footer_widgets” lines? I’m not sure what to put if that’s the case. I have tried changing it to just “disable_footer_widgets”.

    The title of the widget area I’m trying to remove is “Secondary Sidebar #1″. Any thoughts? I appreciate it! :)

  7. smi1ey
    smi1ey July 21, 2009 at 12:47 pm | | Reply

    Oh, and to The Frosty. I would assume if you want this to work on a specific page, you would change the code:

    with “#” being the numerical ID of the page. Although again, this hasn’t worked for me, because the code hasn’t worked on single posts or pages with any method I’ve tried so far. But maybe you’ll be luckier!

  8. Coafuri
    Coafuri September 18, 2009 at 7:16 am | | Reply

    Oau..it’s quite simple. Until now i use a special plugin o do that.

  9. Albert
    Albert October 29, 2009 at 7:54 am | | Reply

    @Coafuri,
    Which is the plugin that you use?

  10. TradiArt
    TradiArt July 4, 2010 at 3:03 am | | Reply

    This is a really useful tip.

    Let’s suppose that our WP3 site doesn’t support widgets at all: they aren’t necessary.

    How can we remove from the admin menu area, under “Appearance”, the menu “Widgets” also?

    Thank you!

  11. Cody
    Cody August 21, 2010 at 2:08 am | | Reply

    Hey, why not use the widget logic plugin?

  12. Robert
    Robert October 9, 2010 at 5:32 pm | | Reply

    Hey Justin, nice trick, by the way, i’m playing with this code i made:

    $sidebars_widgets = get_option('sidebars_widgets');
    foreach ($sidebars_widgets as $index=>$widgets) {
    	if ($index!='wp_inactive_widgets' && $index!='array_version') {
    		if(!empty($widgets) ){
    			foreach($widgets as $n){
    				echo 'Widgets in use: '.$n.'';
    			}
    		}
    	}
    	if($index=='wp_inactive_widgets'){
    			foreach($widgets as $n){
    				echo 'Widgets inactive: '.$n.'';
    			}
    	}
    }

    There you can see i’m able to get all active and inactive widgets, not the widgets areas, each widget id.

    So, then i can run a single wp_unregister_sidebar_widget([some_id]); to disable any widget from any page or post.

    But, i can’t figure how to do the reverse thing, i mean to register dinamicly one of the inactive ones in a certain widget area.

    Got what i mean?

    Well, that’s it, you have my email, pleas reply if you found how to. Thanks.

  13. Jon Brown
    Jon Brown December 12, 2010 at 9:30 am | | Reply

    I can’t get this to work targeting a single widget… Maybe I’m misreading the post though.

    I can remove a single “widget area”, ie. an entire sidebar, but can’t seem to target individual widgets within a widget area.

    This works:

    add_filter ('sidebars_widgets', 'remove_text_widget');
    function remove_text_widget( $sidebars_widgets ){
    	if (is_page(15))
    		$sidebars_widgets ['sidebar'] = false;
    	return $sidebars_widgets;
    }

    This doesn’t:

    add_filter ('sidebars_widgets', 'remove_text_widget');
    function remove_text_widget( $sidebars_widgets ){
    	if (is_page(15))
    		$sidebars_widgets ['text-5'] = false;
    	return $sidebars_widgets;
    }
  14. Eric S
    Eric S December 14, 2010 at 2:53 pm | | Reply

    This looks like it is exactly what I need. Thank you

    I could use some help though /*noob alert*/

    Where is the proper place to paste the code that Justin provided at the beginning of this post. I know it’s in the functions.php file, but where specifically should it be posted. I see other filters in the file, but every time I paste it, I get an error…

    Thanks for your help!

  15. Rodney Corle
    Rodney Corle May 5, 2011 at 11:05 am | | Reply

    Very good blog! Do you have any hints for aspiring writers? I’m planning to start my own site soon but I’m a little lost on everything. Would you suggest starting with a free platform like Wordpress or go for a paid option? There are so many choices out there that I’m totally overwhelmed .. Any suggestions? Appreciate it!

  16. Tony
    Tony August 10, 2011 at 2:14 pm | | Reply

    Is it possible to disable all widgets on a per page basis? If so, how? Thanks!

  17. Matt
    Matt September 29, 2011 at 11:04 pm | | Reply

    Even better would be to do this in a child theme with its own functions.php file that way you really aren’t editing the theme files at all. Of course you have to stop a tutorial somewhere…

  18. Balu
    Balu December 19, 2011 at 8:10 am | | Reply

    Remove this code from index.php
    get_sidebar();

Leave a Reply

By submitting a comment here you grant this site a perpetual license to reproduce your words and name/Web site in attribution.

Please use your real name or a pseudonym (i.e., pen name, alias, nom de plume) when commenting. If you add your site name, company name, or something completely random, I'll likely change it to whatever I want.