Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

share|improve this question

3 Answers 3

up vote 5 down vote accepted

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

share|improve this answer

This is the old (and difficult) way to create WordPress widgets. Use the Widget API instead: http://codex.wordpress.org/Widget_API.

share|improve this answer

it give a param for description in array of the function to register widget:

register_sidebar()

Example can you see on this post or this code.

if ( function_exists('register_sidebar') ) {
    register_sidebar(array(
        'name' => 'My Lorem Ipsum Sidebar',
        'description' => __('Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.', 'your_textdomain'),
        'before_widget' => '<li id="%1$s" class="widget %2$s">',
        'after_widget' => '</li>',
        'before_title' => '<h2 class="widgettitle">',
        'after_title' => '</h2>',
    ));
}
share|improve this answer
3  
You are adding a new sidebar, I think Jonathan wants to add a new sidebar widget. –  Jan Fabry Dec 7 '10 at 10:08
    
you have right, sorry. the param is also the same. –  bueltge Dec 7 '10 at 19:13

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.