register_widget() WordPress Function

The register_widget() function is used to register a new widget for use in a Wordpress theme. This function takes two arguments: the name of the widget, and an array of options for the widget. The options array can include the following keys: - name: The name of the widget. This will be used as the label for the widget in the Wordpress admin interface. - description: A short description of the widget. This will be displayed in the Wordpress admin interface. - classname: The CSS classname to use for the widget. - width: The width of the widget, in pixels. - height: The height of the widget, in pixels. - id: The HTML id to use for the widget.

register_widget( string|WP_Widget $widget ) #

Register a widget


Description

Registers a WP_Widget widget

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 ↑

Source

File: wp-includes/widgets.php

function register_widget( $widget ) {
	global $wp_widget_factory;

	$wp_widget_factory->register( $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.