Post type select

Post type select field renders a searchable Select 2arrow-up-right field that will provide a list of post type titles when a user has typed at least two characters (the values will be loaded dynamically). Similar to the Datalist field. Supports multiple choice.

Description

The field uses AJAXarrow-up-right to load the values dynamically, so depending on your configuration, there may be some latency before the results are presented to the user. Uses the Search Parameterarrow-up-right of the WP_Query class on the back end.

Example configuration

...
array(
    'title' => 'My post type select field title',
    'id' => 'post-type-select-option',
    'desc' => 'Short description for the field',
    'tab' => 'main',
    'post-type' => 'page',
    'type' => 'post-type-select',
),
...

This will produce the following

Multiple choice

if 'multiple' => true is added to the configuration object, the field will respect it. The following configuration

will result in the following

Params

Name

Type

Description

type

string

post-type-select (required)

id

string

Unique ID that will be used to retrieve the value (required)

tab

string

Specifies in which tab this option will be rendered

title

string

Shows a heading to the left of the field

desc

string

Shows a description text (can have HTML)

multiple

boolean

Set to true if multiple values are needed. See an example above.

post-type

string

Post type (standard or custom) to search for. If not specified, searches posts of the post type.

Last updated