I’m listing all sidebars like that:
global $wp_registered_sidebars;
echo '<pre>';
print_r($wp_registered_sidebars);
echo '</pre>'
So I’m getting something like:
Array
(
[sidebar-1] => Array
(
[name] => Sidebar #1
[id] => sidebar-1
List all sidebar names? => Sidebar number 1
[before_widget] =>
[after_widget] =>
[before_title] =>
[after_title] =>
)
(...)
)
But I’d love to display them as a select list, like:
<select>
<option value ="SIDEBAR-ID">SIDEBAR-NAME/option>
<option value ="SIDEBAR-ID">SIDEBAR-NAME/option>
(...)
</select>
WordPress Codex isn’t helpful at all.
Thank you!
Loop through the global:
<select>
<?php foreach ( $GLOBALS['wp_registered_sidebars'] as $sidebar ) { ?>
<option value="<?php echo ucwords( $sidebar['id'] ); ?>">
<?php echo ucwords( $sidebar['name'] ); ?>
</option>
<?php } ?>
</select>
Note:
The ucwords()
function is only there to display it exactly as you asked. Not sure if you really want that.
How to access global arrays & objects:
Anyway: Your Q mostly is about how to access arrays. I wrote a Q about that (for further explanation). Please take a look over here.