Codex tools: Log in
Contents |
Register WordPress Widgets for use in your themes sidebars. You can also modify your theme and start Customizing Your Sidebar.
<?php wp_register_sidebar_widget( $id, $name, $output_callback, $options, $params, ... ); ?>
function my_output_callback_function( $args, $params ){ ... }
$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.
<?php
function your_widget_display($args) {
extract($args);
echo $before_widget;
echo $before_title . 'My Unique Widget' . $after_title;
echo $after_widget;
// print some HTML for the widget to display here
echo "Your Widget Test";
}
wp_register_sidebar_widget(
'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'
)
);
?>
Since: 2.2.0
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()