• Hi all,

    I am in the middle of developing plugin and widget in the correct way.

    After asking Google for a while, I realised that having plugin widgetized can be as easy as registering them:

    $widget_ops = array('classname' => 'the_class_name', 'description' => __( "the_description") );
    wp_register_sidebar_widget('thewidget', 'the_widget_name', 'the_function_name', $widget_ops);

    (in this case, using register_sidebar_widget or wp_register_sidebar_widget does not matter, although I know there are some debates on which to use)

    However, I later realized that by registering so, I can only use the widget once in all of the sidebar.

    Now that I have multiple sidebars defined, and I want to add the widget to all of the sidebars. How?

    I realised that Text widget is doing exactly the same thing that I want to achieve here. But bear with me that I am not a Pro, I found that it is way too confusing for me @@ (especially the widget name Text and the field name text, argh..)

    Wonder if any of you have a simple sample or demo on this? I’ve tried asking Google this but Google didnt really answering me properly :s

    Thanks!!

Viewing 4 replies - 1 through 4 (of 4 total)
  • look in the widgets.php file (in wp-includes). Right at the bottom is a good example of how to set things up.

    It may take a while to get your head around it – but it’s worth it in the end.

    The method mentioned above limits how many you can activate, this correct method doesn’t.

    Even this “correct” method requires any widget that you want represented in multiple sidebars to be modified. From an OO standpoint, I’m not buying that this is the correct way to handle the problem for all cases.

    For a widget like the text widget that needs each instance to have it’s own unique data I can see the need to create multiple instances. But many widgets should not be treated this way and should always display the same content for all sidebars they happen to be a member of.

    There’s a hack that appears to be more appropriate for the single instance displaying in multiple sidebars case. I haven’t tried it yet, but I’m looking at this approach for a site I’m working on. I don’t want to modify all of the widgets that I want replicated.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Widgets into multiple sidebars’ is closed to new replies.