0

I have multiple sidebars, based on different pages. How can I get the WP125 widget to show on all of them?? Once I add it to one sidebar, it is unavailable to put on others (like many other widgets by the way).

Just to clarify, just multiple instances of the widget with the same content. In other words, the same widget but on more than one page (with different sidebars)

Below the registration function:

//Create Widget
function wp125_create_ad_widget() {
        register_sidebar_widget(__('WP125'), 'wp125_write_ads_widget');
}

Below the line I added to see if another widget is created in the widget area:

        register_sidebar_widget(__('WP125-2'), 'wp125_write_ads_widget'); //nothing happens with this line added.

The rest of the wp125.php file:

function wp125_write_ads_widget($args) {
        extract($args);
        echo $before_widget;
        if (get_option("wp125_widget_title")!='') {
                echo "\n".$before_title; echo get_option("wp125_widget_title"); echo $after_title;
        }
        wp125_write_ads();
        echo $after_widget;
}
2
  • I think you might be after The Widget(the_widget())
    – t31os
    Feb 28, 2011 at 19:37
  • I am not sure I follow how to use the_widget(the_widget()). could you include an answer with more detail for my benefit? Thanks.
    – Geo
    Mar 2, 2011 at 12:53

2 Answers 2

1

You have two options:

Create the widget yourself with the "new" widget api as a class an it will be multiple instance widget.

Or find the line that registers the widget and register the same widget with a new name for example find:

register_sidebar_widget(array('Content License', 'widgets'), 'widget_cc');

and replace with:

register_sidebar_widget(array('Content License 1', 'widgets'), 'widget_cc');
register_sidebar_widget(array('Content License 2', 'widgets'), 'widget_cc');
register_sidebar_widget(array('Content License 3', 'widgets'), 'widget_cc');
register_sidebar_widget(array('Content License 4', 'widgets'), 'widget_cc');
2
  • See my comments, I tried your suggestion, but nothing happened on the widget area.
    – Geo
    Feb 27, 2011 at 17:22
  • first you should use wp_register_sidebar_widget instead of register_sidebar_widget i was showing an example, second once you do use wp_register_sidebar_widget give it a different id and name each time you register it. read more about wp_register_sidebar_widget codex.wordpress.org/Function_Reference/…
    – Bainternet
    Feb 27, 2011 at 18:13
0

//Create Widget
function wp125_create_ad_widget() {
register_sidebar_widget(__('WP125'), 'wp125_write_ads_widget');
}

replace the above function with the below function,

//Create Widget
function wp125_create_ad_widget() {
wp_register_sidebar_widget(__('WP125 1'),'WP125', 'wp125_write_ads_widget');
wp_register_sidebar_widget(__('WP125 2'),'WP125', 'wp125_write_ads_widget');
}

its work for me, wish its help you.

1
  • Please explain that.
    – fuxia
    Nov 4, 2012 at 0:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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