62 Responses

  1. Stephen Cronin
    Stephen Cronin Published |

    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 Published |

    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 Published |

    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 Published |

      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 Published |

        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 at |
  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 Published |

    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 Published |

    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 Published |

    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 Published |

    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 Published |

    @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 Published |

    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 Published |

    Hey, why not use the widget logic plugin?

    Reply
  30. Robert
    Robert Published |

    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 Published |

    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 Published |

    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 Published |

    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 Published |

    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 Published |

    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 Published |

    Remove this code from index.php
    get_sidebar();

    Reply
  38. Chris Lynn
    Chris Lynn Published |

    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 Published |

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

    Reply
  40. Joseph
    Joseph Published |

    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 Published |

    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
  44. functions.php模板妙用 | 那甲山文化传媒
  45. Fadil Shamir Khan
    Fadil Shamir Khan Published |

    “Remove this code from index.php

    get_sidebar();”

    I tried this and it worked. My only issue now is that my images and text remains the same size….it does not expand to where the sidebar was….

    How do I fix that?

    Take a look here!

    http://microhounds.co.nf/

    Reply
  46. Rudi Nazar
    Rudi Nazar Published |

    I want to ask, how to delete widgets on a specific page?

    Reply
  47. sutopo
    sutopo Published |

    Very good article! We are linking to this great post on our site. Keep up the great writing.

    Reply
  48. sandal terbaru
    sandal terbaru Published |

    its nice post justin…realy helpfull keep sharing and keep it up..

    but i want to ask you somthing,how to manage widgets visibility on a specific page?

    thanks for your help

    Reply
  49. NJ
    NJ Published |

    I got a horrible error stating that there is a sytax error

    How do I fix it? It won’t let me go back into the editor!

    Reply
    1. Nicolette
      Nicolette Published |

      how did you fix the syntax error?

      Reply
  50. Random Joe
    Random Joe Published |

    Very good article! But I want to ask, how to hide widgets on a specific page?

    Reply
  51. Liz
    Liz Published |

    What is a functions.php file and where is it? I know very little and do not see it when I click on text. I only have the Widget on one page (Horticulture) and that page is not publishing.

    Reply
  52. Arif
    Arif Published |

    Thanks.. how to hide widgets on a specific page?

    Reply
  53. Xenia Jogja
    Xenia Jogja Published |

    Articles of interest. helpful to me in improving a website that I have.

    Reply
  54. troy
    troy Published |

    Hi

    Im breaking my head to try to figure out why my theme doesnt show the sidebar or footer widgets:

    http://tinyurl.com/qdyd8pk

    could you please help with this?

    Reply
  55. Colber Blog » functions.php模板妙用
  56. Nicolette
    Nicolette Published |

    HELLO

    I know this thread is kind of old but has anyone figured out what to do when the syntax error happens???? I removed all codes I placed in the functions and it’s still happening. Pretty much I can’t move forward.

    Help please!

    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.

css.php