Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/wp register sidebar widget


Register WordPress Widgets for use in your themes sidebars. You can also modify your theme and start Customizing Your Sidebar.




(int/string) (required) Widget ID.
Default: None
(string) (required) Widget display title.
Default: None
(callback) (required) Run when widget is called.
Default: None
(array/string) (optional) Widget Options.
Default: None
(mixed) (optional) Widget parameters to add to widget.
Default: None

Output Callback Function Parameters Format

function my_output_callback_function( $args, $params ){ ... }

(array) (required) Various values merged into an array
Default: None
(array) (required) The extra $params given to wp_register_sidebar_widget, as an array
Default: None

$args array contains:

The 'dynamic_sidebar_params' filter is applied to the parameters (as an array), before your output function is called back.


The following code will create a widget called "Your Widget" which will become available in the WordPress Administrative Panels. The widget can then be dragged to an available sidebar for display.

Note that this widget can only be used once in exactly 1 of the sidebars. For recursive widgets (widgets you can add to multiple times and add to multiple sidebars) please see the Register Widget function.


function your_widget_display($args) {
   echo $args['before_widget'];
   echo $args['before_title'] . 'My Unique Widget' .  $args['after_title'];
   echo $args['after_widget'];
   // print some HTML for the widget to display here
   echo "Your Widget Test";

    'your_widget_1',        // your unique widget id
    'Your Widget',          // widget name
    'your_widget_display',  // callback function
    array(                  // options
        'description' => 'Description of what your widget does'


Change Log

Since: 2.2.0

Source File

wp_register_sidebar_widget() is located in wp-includes/widgets.php.


Sidebars: is_active_sidebar(), is_dynamic_sidebar(), dynamic_sidebar(), register_sidebars(), register_sidebar(), unregister_sidebar(), wp_register_sidebar_widget(), wp_unregister_sidebar_widget(), wp_get_sidebars_widgets(), wp_set_sidebars_widgets()

See also index of Function Reference and index of Template Tags.