Get all WordPress sidebars
global-variables, php, wordpress
Solution
Please try this
https://wordpress.stackexchange.com/questions/13450/list-all-sidebar-names
you get all the sidebar name lists
Problem
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?