retrieve_widgets ( $theme_changed = false )

  • (string|bool) theme_changed Whether the theme was changed as a boolean. A value of 'customize' defers updates for the Customizer.
  • (array) Updated sidebars widgets.
Defined at:


Validates and remaps any "orphaned" widgets to wp_inactive_widgets sidebar, and saves the widget settings. This has to run at least on each theme change.For example, let's say theme A has a "footer" sidebar, and theme B doesn't have one. After switching from theme A to theme B, all the widgets previously assigned to the footer would be inaccessible. This function detects this scenario, and moves all the widgets previously assigned to the footer under wp_inactive_widgets. Despite the word "retrieve" in the name, this function actually updates the database and the global `$sidebars_widgets`. For that reason it should not be run on front end, unless the `$theme_changed` value is 'customize' (to bypass the database write).

Related Functions

register_widget, the_widget, unregister_widget, is_active_widget, wp_render_widget

Top Google Results

User discussions

wpseek mobile