unregister_widget() WordPress Function

The unregister_widget() function is used to unregister a widget from the WordPress widgets system. This function can be used to unregister a built-in WordPress widget, or a widget provided by a plugin.

unregister_widget( string|WP_Widget $widget ) #

Unregisters a widget.


Description

Unregisters a WP_Widget widget. Useful for un-registering default widgets. Run within a function hooked to the ‘widgets_init’ action.

Top ↑

See also


Top ↑

Parameters

$widget

(string|WP_Widget)(Required)Either the name of a WP_Widget subclass or an instance of a WP_Widget subclass.


Top ↑

More Information

List of WP_Widget subclass names:

WP_Widget_Pages = Pages Widget
WP_Widget_Calendar = Calendar Widget
WP_Widget_Archives = Archives Widget
WP_Widget_Links = Links Widget
WP_Widget_Media_Audio = Audio Player Media Widget
WP_Widget_Media_Image = Image Media Widget
WP_Widget_Media_Video = Video Media Widget
WP_Widget_Media_Gallery = Gallery Media Widget
WP_Widget_Meta = Meta Widget
WP_Widget_Search = Search Widget
WP_Widget_Text = Text Widget
WP_Widget_Categories = Categories Widget
WP_Widget_Recent_Posts = Recent Posts Widget
WP_Widget_Recent_Comments = Recent Comments Widget
WP_Widget_RSS = RSS Widget
WP_Widget_Tag_Cloud = Tag Cloud Widget
WP_Nav_Menu_Widget = Menus Widget
WP_Widget_Custom_HTML = Custom HTML Widget


Top ↑

Source

File: wp-includes/widgets.php

function unregister_widget( $widget ) {
	global $wp_widget_factory;

	$wp_widget_factory->unregister( $widget );
}


Top ↑

Changelog

Changelog
VersionDescription
4.6.0Updated the $widget parameter to also accept a WP_Widget instance object instead of simply a WP_Widget subclass name.
2.8.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.