I'm trying to add multiple options to a select field, if I do this by just filling in keys and values into an array() and using this array into your code it works fine!
$twosectors = array(
'belleza'=>'Belleza',
'centros-estetica'=> 'Centros de estética',
'centros-depilacion-laser'=>'Centros depilación laser',
'centros-manicura-pedicura'=>'Centros manicura y pedicura',
'peluquerias'=>'Peluquerías',
'tatuajes-piercings'=>'Tatuajes y piercings'
);
But if I'm trying to do the same but filling keys and values from terms, it does not work... options stay empty.
Comparing arrays content they are just the same, why doesn't it work ?
Problems on filling 'options' for select fields.
I'm trying to add multiple options to a select field, if I do this by just filling in keys and values into an array() and using this array into your code it works fine!
$twosectors = array( 'belleza'=>'Belleza', 'centros-estetica'=> 'Centros de estética', 'centros-depilacion-laser'=>'Centros depilación laser', 'centros-manicura-pedicura'=>'Centros manicura y pedicura', 'peluquerias'=>'Peluquerías', 'tatuajes-piercings'=>'Tatuajes y piercings' );
$my_meta->addSelect($prefix.'select_field_id',$twosectors,array('name'=> __('Related sector 1 ','tax-meta'), 'std'=> array('Related ')));
But if I'm trying to do the same but filling keys and values from terms, it does not work... options stay empty. Comparing arrays content they are just the same, why doesn't it work ?
$mysectors = array(); $args = array( 'taxonomy' => 'sector', 'hide_empty' => 0 );
$myterms= get_terms($args); if (isset($myterms) ) { foreach ( $myterms as $myterm ) { $name = $myterm->name; $slug = $myterm->slug; $mysectors[$slug]=$name;
}
$my_meta->addSelect($prefix.'select_field_id',$mysectors,array('name'=> __('Related sector 1 ','tax-meta'), 'std'=> array('Related ')));
I would be very happy to get it to work!
Thanks for your marvelous script!