radio(sample)

Display a set of radio buttons.

Option Details & Parameters

Type: radio

Returns: string

Can be placed in: Admin Panels , Admin Tabs , Meta Boxes , Theme Customizer

Parameter Type Description
name string The name of the option, for display purposes only.
id string A unique ID for this option. This ID will be used to get the value for this option.
options array An associative array containing value – label pair options displayed as radio buttons.
desc string (Optional) The description to display together with this option.
default string (Optional) The default value for this option.
livepreview string (Optional) jQuery code that updates something in your site in the live preview. Only used when the option is placed in a theme customizer section. Refer to Livepreview for more information on this parameter.
css string (Optional) CSS rules to be used with this option. Only used when the option is placed in an admin page / panel or a theme customizer section. Refer to Generate CSS Automatically for your options for more information on this parameter.

Examples

Creating a radio option:

$panel->createOption( array(
'name' => 'My Radio Option',
'id' => 'my_radio_option',
'options' => array(
'1' => 'Option one',
'2' => 'Option two',
'3' => 'Option three',
),
'type' => 'radio',
'desc' => 'Select one',
'default' => '2',
) );

Notes

[zilla_alert]Reminder, only one value can be selected in a set of radio buttons.

If you’re displaying a lot of options, it may be better to use a select option[/zilla_alert]