unregister_widget( string|WP_Widget $widget )
Unregisters a widget.
Description Description
Unregisters a WP_Widget widget. Useful for un-registering default widgets. Run within a function hooked to the ‘widgets_init’ action.
See also See also
Parameters Parameters
- $widget
-
(string|WP_Widget) (Required) Either the name of a
WP_Widgetsubclass or an instance of aWP_Widgetsubclass.
Source Source
File: wp-includes/widgets.php
function unregister_widget( $widget ) {
global $wp_widget_factory;
$wp_widget_factory->unregister( $widget );
}
Expand full source code Collapse full source code View on Trac
Changelog Changelog
| Version | Description |
|---|---|
| 4.6.0 | Updated the $widget parameter to also accept a WP_Widget instance object instead of simply a WP_Widget subclass name. |
| 2.8.0 | Introduced. |
User Contributed Notes User Contributed Notes
You must log in before being able to contribute a note or feedback.
Example
This will un-register the built-in WP_Widget_Calendar widget (useful if you wish to replace the built-in version).
function wpdocs_remove_calendar_widget() { unregister_widget( 'WP_Widget_Calendar' ); } add_action( 'widgets_init', 'wpdocs_remove_calendar_widget' );Available parameters (from the Codex):