Override dynamic_sidebar() in plugin?

dynamic_sidebar() calls wp_get_sidebars_widgets() to get the list of all sidebars and their widgets. This output is filtered through sidebars_widgets, so you can modify it to add or remove widgets.

This array only contains widget IDs, so you need to register the widget instance too (it should end up in the global $wp_registered_widgets array). I think you can do this with wp_register_sidebar_widget(), but it is possible that this is older code from the time when a widget could not have multiple instances yet.

Leave a Comment