More than 1 widget in wordpress

Following is my code

$op=array("description"=>"Ads Widget");
    wp_register_sidebar_widget('adswidget','Ads','ads_widget',$op);
    register_widget_control('adswidget','ads_widget_control');

I can use only 1 Ads Widget. I want to use more than 1 Ads Widget ? How to write it ? I’m finding in google and still not found.

Read More

Still not found document on

http://codex.wordpress.org/Function_Reference/wp_register_sidebar_widget

also.

Related posts

Leave a Reply

2 comments

  1. By default all widgets that are created using the widgets api are multi instance.

    The code you have above is the old method before WordPress 2.8. Now you just need to extend the widget class and add some functions. Default Example:

    class My_Widget extends WP_Widget {
    function My_Widget() {
        // widget actual processes
    }
    
    function form($instance) {
        // outputs the options form on admin
    }
    
    function update($new_instance, $old_instance) {
        // processes widget options to be saved
    }
    
    function widget($args, $instance) {
        // outputs the content of the widget
    }
    
    }
    register_widget('My_Widget');
    

    See Codex Page: http://codex.wordpress.org/Plugins/WordPress_Widgets_Api