I’m trying to get a list with all registered sidebars using $wp_registered_sidebars but the global variable returns an empty array.
function get_sidebars() {
global $wp_registered_sidebars;
$sidebar_options = array();
foreach ($wp_registered_sidebars as $sidebar)
{
$sidebar_options[$sidebar['id']] = $sidebar['name'];
}
return $sidebar_options;
}
$fields['sidebar_settings'] = array(
'active' => array(
...
'values' => get_sidebars(),
...
),
);
Why is the global variable empty and is there another way to store all registered sidebars in an array?
Please try this
https://wordpress.stackexchange.com/questions/13450/list-all-sidebar-names
you get all the sidebar name lists
Heres some functions that you could be looking for:
dynamic_sidebar
wp_get_sidebars_widgets
See this: http://codex.wordpress.org/Sidebars . There’s also some good information.