Skip to main content

Select

Dropdown input with optional multi-select support

Value

Returns multiple false (string|number)

$value = fx_get_meta('id');

Returns multiple true (string|number)[]

$value = json_decode(fx_get_meta('id'), true);

Example

'id' => [
'type' => 'select',
'className' => 'my-class-name',
'creatable' => false,
'excludePostType' => false,
'multiple' => true,
'options' => 'page, post',
'placeholder' => 'Pick some content',
'wrapperClassName' => 'wrapper-class-name',
],

Functions

Used in conjunction with creatable: true. Allows a user to input an external link or choose a post. The function detects the two and outputs either a permalink, or external link accordingly.

echo fx_get_url_from_select('id');

Props

className

Metabox class name

type: string

creatable

Allow new options to be created

type: bool

defaultValue: false

exclude

A list of ids to exlude from the options list

type: array

excludePostType

Hide the post type if the option is a post

type: bool

defaultValue: false

label

Optional label that appears next to the input, rather than ontop

type: string

multiple

Allow multiple selections

type: bool

defaultValue: false

options (required)

Options to choose from. See options for more information.

type: array

placeholder

Placeholder text for the input

type: string

defaultValue: 'Please select...'

title

Metabox title

type: string

wrapperClassName

Metabox wrapping div class name

type: string