Skip to content

Choice

Pick one or many from a set of options. Single-select fields store a string, multi-select fields store an array, boolean toggles store true/false.

TypeDescriptionStored as
selectDropdown. args.multiple: true for searchable tag inputstring or array
radioRadio button groupstring
image_radioSingle-select with image swatches per optionstring
checkboxesMultiple checkboxesarray
image_checkboxesMulti-select with image swatchesarray
toggleOn/off switchbool
checkboxSingle checkboxbool

All choice fields accept an options map in args — value as the key, label as the value:

'args' => [
'options' => [
'draft' => 'Draft',
'published' => 'Published',
'archived' => 'Archived',
],
],

Image variants take a slightly richer shape — image key per option:

'args' => [
'options' => [
'card' => ['label' => 'Card', 'image' => 'https://…/card.png'],
'list' => ['label' => 'List', 'image' => 'https://…/list.png'],
],
],
[
'id' => 'categories',
'type' => 'select',
'label' => __('Categories', 'my-plugin'),
'default' => ['news'],
'columns' => 6,
'args' => [
'multiple' => true,
'options' => [
'news' => 'News',
'blog' => 'Blog',
'reviews' => 'Reviews',
],
],
],
[
'id' => 'notifications',
'type' => 'toggle',
'label' => __('Enable notifications', 'my-plugin'),
'description' => __('Send alerts when settings change.', 'my-plugin'),
'default' => true,
],
[
'id' => 'layout',
'type' => 'image_radio',
'label' => __('Layout', 'my-plugin'),
'default' => 'card',
'args' => [
'options' => [
'card' => [
'label' => __('Card', 'my-plugin'),
'image' => plugins_url('img/layout-card.png', __FILE__),
],
'list' => [
'label' => __('List', 'my-plugin'),
'image' => plugins_url('img/layout-list.png', __FILE__),
],
],
],
],