How do I completely remove widget support from a theme/plugin ?
Like removing the appearance -> widgets page, and prevent WP from loading widget classes and all widget-related stuff.
How do I completely remove widget support from a theme/plugin ?
Like removing the appearance -> widgets page, and prevent WP from loading widget classes and all widget-related stuff.
You must be logged in to post a comment.
One option would be to simply flush the widget code out of the sidebar.php file, as well as the header/footer/post pages if they are using widgets.
However, take a peek at this code snippet (courtesy of this site), which you can add to your functions.php file and will disable the widgets. I think this would be a cleaner approach if you’re looking to change themes and sill have widgets disabled.
Note that this will only disable the widgets on your home page, so you’ll need to find the additional conditionals for individual pages/posts/etc.
If you make use of the internal functions from
widgets.php
, then it’s as easy as this:remove_theme_support(‘widgets’) won’t work because of:
The “Widgets” menu item is added by
wp_widgets_add_menu()
, called in the_admin_menu
hook, as set up bywp_maybe_load_widgets()
. You can disable this by unhooking it from_admin_menu
or returning false forload_default_widgets
.You can also unregister all sidebars as Bainternet suggested, and
remove_theme_support( 'widgets' )
.