unregister_widget()
Unregisters a widget.
Unregisters a WP_Widget widget. Useful for un-registering default widgets. Run within a function hooked to the widgets_init action.
No Hooks.
Return
null
. Nothing.
Usage
unregister_widget( $widget );
- $widget(string|WP_Widget) (required)
- Either the name of a WP_Widget subclass or an instance of a WP_Widget subclass.
Notes
- See: WP_Widget
- Global. WP_Widget_Factory. $wp_widget_factory
Changelog
Since 2.8.0 | Introduced. |
Since 4.6.0 | Updated the $widget parameter to also accept a WP_Widget instance object instead of simply a WP_Widget subclass name. |
Code of unregister_widget() unregister widget WP 5.9.3
function unregister_widget( $widget ) { global $wp_widget_factory; $wp_widget_factory->unregister( $widget ); }