WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to add a metabox to select a sidebar per page. In order to create the metaboxes I use this class

The construction is fairly easy:

$meta_boxes[] = array(
    'id' => 'sidebars_side',
    'title' => 'Page Sidebar',
    'pages' => array('page', 'post'),
    'context' => 'side',
    'priority' => 'low',

    'fields' => array(
            'name' => 'Sidebars',
            'id' => 'tst_sidebars',
            'type' => 'select',
            'options' => array(                      

            'multiple' => false,


But I can't for the love of God to construct the array properly. I checked this post

which is great, but I'm stuck somehow. Any help would be highly appreciated.

share|improve this question
up vote 4 down vote accepted

The class you are using accepts value => name pair in the select options array so

foreach ( $GLOBALS['wp_registered_sidebars'] as $sidebar ) { 
    $sidebar_options[$sidebar['id']] = $sidebar['name'];

and then you can use $sidebar_options.

share|improve this answer
Fantastic, thank you. – Jukov Jun 16 '11 at 0:21

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.