-
Notifications
You must be signed in to change notification settings - Fork 142
Field example: Select
Morgan Estes edited this page Jun 11, 2015
·
4 revisions
Here's how you can use a select
field with pre-populated options within the registration of your Shortcode UI.
array(
'label' => 'Field Label',
'attr' => 'yourshortcodeattribute',
'type' => 'select',
'options' => array(
'value1' => 'Label 1',
'value2' => 'Label 2',
'value3' => 'Label 3',
),
),
If you're using select
for number range, you can shorten the 'options'
value:
array(
'label' => __( 'Number of Items', 'your-text-domain' ),
'attr' => 'items',
'type' => 'select',
'options' => array_combine( range( 1, 20 ), range( 1, 20 ) ), // Matches the key to value, starting with 1
'multiple' => false,
),