How to add a description to Widgets?

The codex doesn’t seem to say how one would go about adding a description to a custom widget registered with wp_register_sidebar_widget(). The default description seems to be the name of teh widget itself.

function myFunc(){
  /* widget code */
}
wp_register_sidebar_widget( 'wdgt1', 'Site Map', 'myFunc', array() );

alt text

3 Answers
3

Here’s what you looking for:

class WP_Widget_Sitemap extends WP_Widget {

    function WP_Widget_Sitemap() {
        $widget_ops = array( 'classname' => 'widget_sitemap', 'description' => __( "This is the description" ) );
        $this->WP_Widget( 'sitemap', __('Site Map'), $widget_ops);
    }

    function widget() { ... }
    function form() { ... }
    function update() { ... }
...

See: http://codex.wordpress.org/Widgets_API#Developing_Widgets

Leave a Comment