Title: unregister_widget
Published: April 25, 2014
Last modified: April 28, 2025

---

# unregister_widget( string|WP_Widget $widget )

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/unregister_widget/?output_format=md#description)
    - [See also](https://developer.wordpress.org/reference/functions/unregister_widget/?output_format=md#see-also)
 * [Parameters](https://developer.wordpress.org/reference/functions/unregister_widget/?output_format=md#parameters)
 * [More Information](https://developer.wordpress.org/reference/functions/unregister_widget/?output_format=md#more-information)
 * [Source](https://developer.wordpress.org/reference/functions/unregister_widget/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/unregister_widget/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/unregister_widget/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/functions/unregister_widget/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/functions/unregister_widget/?output_format=md#wp--skip-link--target)

Unregisters a widget.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/unregister_widget/?output_format=md#description)󠁿

Unregisters a [WP_Widget](https://developer.wordpress.org/reference/classes/wp_widget/)
widget. Useful for un-registering default widgets.
Run within a function hooked 
to the [‘widgets_init’](https://developer.wordpress.org/reference/hooks/widgets_init/)
action.

### 󠀁[See also](https://developer.wordpress.org/reference/functions/unregister_widget/?output_format=md#see-also)󠁿

 * [WP_Widget](https://developer.wordpress.org/reference/classes/wp_widget/)

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/unregister_widget/?output_format=md#parameters)󠁿

 `$widget`string|[WP_Widget](https://developer.wordpress.org/reference/classes/wp_widget/)
required

Either the name of a `WP_Widget` subclass or an instance of a `WP_Widget` subclass.

## 󠀁[More Information](https://developer.wordpress.org/reference/functions/unregister_widget/?output_format=md#more-information)󠁿

List of [WP_Widget](https://developer.wordpress.org/reference/classes/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

## 󠀁[Source](https://developer.wordpress.org/reference/functions/unregister_widget/?output_format=md#source)󠁿

    ```php
    function unregister_widget( $widget ) {
    	global $wp_widget_factory;

    	$wp_widget_factory->unregister( $widget );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/widgets.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/widgets.php#L142)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/widgets.php#L142-L146)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/unregister_widget/?output_format=md#related)󠁿

| Uses | Description | 
| [WP_Widget_Factory::unregister()](https://developer.wordpress.org/reference/classes/wp_widget_factory/unregister/)`wp-includes/class-wp-widget-factory.php` |

Un-registers a widget subclass.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/unregister_widget/?output_format=md#changelog)󠁿

| Version | Description | 
| [4.6.0](https://developer.wordpress.org/reference/since/4.6.0/) | Updated the `$widget` parameter to also accept a [WP_Widget](https://developer.wordpress.org/reference/classes/wp_widget/) instance object instead of simply a `WP_Widget` subclass name. | 
| [2.8.0](https://developer.wordpress.org/reference/since/2.8.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/functions/unregister_widget/?output_format=md#user-contributed-notes)󠁿

 1.  [Skip to note 2 content](https://developer.wordpress.org/reference/functions/unregister_widget/?output_format=md#comment-content-1326)
 2.   [Codex](https://profiles.wordpress.org/codex/)  [  10 years ago  ](https://developer.wordpress.org/reference/functions/unregister_widget/#comment-1326)
 3. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Funregister_widget%2F%23comment-1326)
    Vote results for this note: 1[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Funregister_widget%2F%23comment-1326)
 4. **Example**
 5. This will un-register the built-in [WP_Widget_Calendar](https://developer.wordpress.org/reference/classes/wp_widget_calendar/)
    widget (useful if you wish to replace the built-in version).
 6.     ```php
        function wpdocs_remove_calendar_widget() {
        	unregister_widget( 'WP_Widget_Calendar' );
        }
        add_action( 'widgets_init', 'wpdocs_remove_calendar_widget' );
        ```
    
 7.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Funregister_widget%2F%3Freplytocom%3D1326%23feedback-editor-1326)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Funregister_widget%2F)
before being able to contribute a note or feedback.