48 Responses

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

    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…

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

    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.

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

    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

    Reply
    1. alacaprice
      alacaprice February 1, 2013 at 10:28 am |

      I tried this and something went horribly wrong.
      Now all I get is the following message when I go to the site and cannot get back in to return the code to original.

      Parse error: syntax error, unexpected ‘?’ in /home/content/d/o/n/donstrisht/html/zapatos/wp-content/themes/minimatica/functions.php on line 24

      Do you have any suggestions? I’m pretty much unable to proceed.

      Reply
      1. Anuka
        Anuka April 24, 2013 at 7:01 pm |

        I had the same problem and I solved it deleting:

        if ( is_home() )

  4. links for 2009-03-19 « On New Media
    links for 2009-03-19 « On New Media March 19, 2009 at 3:06 am |
  5. WordPress-10 Exceptional WordPress Hacks | Why? Nowhy! DFdou's Blog
  6. 10 Exceptional WordPress Hacks | Bookmarks
  7. 10 Exceptional WordPress Hacks « the gypsy
  8. 10 Cool WordPress Hacks | Knowledge Base eDynamo
  9. 10 Hacks Per Wordpress Gratis | Sbloggando
  10. 10 New Wordpress Hacks | Themeflash
  11. The Frosty @WPCult
    The Frosty @WPCult June 23, 2009 at 3:10 pm |

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

    Reply
  12. 70 Very Useful Wordpress Hacks & Tricks » De Web Times - Sharing Useful Resources.
  13. 10 Exceptional WordPress Hacks « Web 2.0.
  14. smi1ey
    smi1ey July 21, 2009 at 12:44 pm |

    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! :)

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

    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!

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

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

    Reply
  17. 10 Exceptional WordPress Hacks | 9Tricks.Com - Tips - Tricks - Tutorials
  18. 10 Exceptional WordPress Hacks « Smashing Magazine
  19. 10 исключительных WordPress хаков | АртБухта
  20. Albert
    Albert October 29, 2009 at 7:54 am |

    @Coafuri,
    Which is the plugin that you use?

    Reply
  21. 13 Useful Code Snippets for WordPress Development | Web Design Ledger
  22. 13 Useful Code Snippets for WordPress Development « HUE Designer
  23. WordPress functions.php Template with 15 Essential Custom Functions | Digging into WordPress
  24. wordpress博客主题制作技巧:模板函数妙用 « 小周哥
  25. 10 Exceptional WordPress Hacks « MalarVizhi
  26. WordPress functions.php Template with 15 Essential Custom Functions « MalarVizhi
  27. TradiArt
    TradiArt July 4, 2010 at 3:03 am |

    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!

    Reply
  28. Best Wordpress hacks | devdevote.com
  29. Cody
    Cody August 21, 2010 at 2:08 am |

    Hey, why not use the widget logic plugin?

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

    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.

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

    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;
    }
    Reply
  32. Eric S
    Eric S December 14, 2010 at 2:53 pm |

    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!

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

    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!

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

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

    Reply
  35. common set of custom wordpress functions « Niroze's Weblog
  36. Matt
    Matt September 29, 2011 at 11:04 pm |

    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…

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

    Remove this code from index.php
    get_sidebar();

    Reply
  38. Chris Lynn
    Chris Lynn July 23, 2012 at 5:07 am |

    Justin, is there any workaround for showing widgets on only pages & disabling them on Front Page.

    I’m new to WordPress,any help would be appreciated.

    Reply
  39. Chris Lynn
    Chris Lynn July 23, 2012 at 5:07 am |

    Correction to my last comment I want to show widgets on only posts & not on Homepage

    Reply
  40. Joseph
    Joseph September 25, 2012 at 8:35 am |

    I purchased a real estate theme. The creator of the theme has disabled the ability to show widgets on certain Posts.

    I have included a link to a youtube video that shows what I am trying to do, can someone please take a look and and maybe point me in the right direction?

    I have contacted the theme creator, but he is unwilling to provide support, claiming that his support guy quit on him.

    Here is the link to the video: http://youtu.be/B6Y4r6IKUt4?hd=1

    Reply
  41. Disable Sidebar and Widget Without Plugin - Shellcreeper.com
  42. WordPress functions.php Template with 15 Essential Custom Functions | Ahmed Mohsin
  43. Brad Dalton
    Brad Dalton February 24, 2013 at 6:35 am |

    Justin.

    There’s no need to use wp_reset_query when using conditional tags in the footer?

    http://codex.wordpress.org/Conditional_Tags#In_a_theme.27s_footer.php_file

    Reply

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.