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
See also
Parameters
- $widget
(string|WP_Widget)(Required)Either the name of a
WP_Widgetsubclass or an instance of aWP_Widgetsubclass.
Source
File: wp-includes/widgets.php
function register_widget( $widget ) {
global $wp_widget_factory;
$wp_widget_factory->register( $widget );
}
Expand full source codeCollapse full source codeView on TracView on GitHub
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. |