Arguments
Name Type Default Description id string A unique ID. This ID will be used to get the value type string select Type of field title string Title of the field default array|string Default value from database, if the option doesn’t exist subtitle string Subtitle to display below the title desc string Description to display after the field help string Text to display on right-corner (as hover/popup) the field class string Extra CSS classes (space separated) to append to the field before string Content to display before the field after string Content to display after the field dependency array Define field visibility depending on other field value attributes array Extra HTML attributes to append to the field sanitize string Callback function for sanitizing value validate string Callback function for validating value EXTRAS empty_message string Display to empty text if options empty placeholder string The placeholder to be displayed when nothing is selected chosen bool false Flag to enable ChosenJS style select multiple bool false Flag to allow multiple options choice sortable bool false Flag to allow sortable options choice ajax bool false Flag to allow ajax search options choice options array|string An array of object containing key/value pairs representing the options or use a predefined options (pages posts categories tags menus users sidebars roles post_types) query_args array An associative array of query arguments. Using with (pages posts categories tags menus) settings array An associative array containing arguments for the chosen setting
Query_Args Arguments
Name Type Default Description post_type string Custom post type name taxonomy string Custom taxonomy name posts_per_page number Maximum number of posts to show (for post types) number number Maximum number of posts to show (for taxonomies) orderby string post_title Sort retrieved posts by parameter order string ASC Designates the ascending or descending order of the orderby parameter (ASC | DESC)
Get more query arguments for (posts,pages: wp_query ) and (categories, tags, menus: wp_term_query )
Settings Arguments
Name Type Default Description min_length number 3 Minimum search input length for trigger ajax search width string auto Chosen style width typing_text string Please enter %s or more characters Chosen ajax typing text searching_text string Searching… Chosen ajax searching text no_results_text string No results match Chosen ajax no results text
Simple Select Field Example
array(
'id' => 'example-select',
'type' => 'select',
'title' => 'Example Select',
'placeholder' => 'Select an option',
'options' => array(
'opt1' => 'Option One',
'opt2' => 'Option Two',
'opt3' => 'Option Three',
),
'default' => 'opt3',
),
Select Field Example with Groups
array(
'id' => 'example-select',
'type' => 'select',
'title' => 'Example Select',
'placeholder' => 'Select an option',
'options' => array(
'Group 1' => array(
'opt1' => 'Option One',
'opt2' => 'Option Two',
'opt3' => 'Option Three',
),
'Group 2' => array(
'opt4' => 'Option Four',
'opt5' => 'Option Five',
'opt6' => 'Option Six',
),
),
'default' => array('opt3','opt6'),
),
Select Field Example with Chosen
array(
'id' => 'example-select',
'type' => 'select',
'title' => 'Example Select',
'chosen' => true,
'placeholder' => 'Select an option',
'options' => array(
'opt1' => 'Option One',
'opt2' => 'Option Two',
'opt3' => 'Option Three',
'opt4' => 'Option Four',
'opt5' => 'Option Five',
'opt6' => 'Option Six',
),
'default' => 'opt3',
),
Select Field Example with Multiple Chosen
array(
'id' => 'example-select',
'type' => 'select',
'title' => 'Example Select',
'chosen' => true,
'multiple' => true,
'placeholder' => 'Select an option',
'options' => array(
'opt1' => 'Option One',
'opt2' => 'Option Two',
'opt3' => 'Option Three',
'opt4' => 'Option Four',
'opt5' => 'Option Five',
'opt6' => 'Option Six',
),
'default' => array('opt3','opt4'),
),
Select Field Example with Chosen AJAX Search
//Select with AJAX search Pages
array(
'id' => 'example-select',
'type' => 'select',
'title' => 'Select with pages',
'placeholder' => 'Select a page',
'chosen' => true,
'ajax' => true,
'options' => 'pages',
),
//Select with multiple and sortable AJAX search Posts
array(
'id' => 'example-select-2',
'type' => 'select',
'title' => 'Select with posts',
'placeholder' => 'Select posts',
'chosen' => true,
'ajax' => true,
'multiple' => true,
'sortable' => true,
'options' => 'posts',
),
//Select with multiple and sortable AJAX search Categories
array(
'id' => 'example-select-3',
'type' => 'select',
'title' => 'Select with categories',
'placeholder' => 'Select categories',
'chosen' => true,
'ajax' => true,
'multiple' => true,
'sortable' => true,
'options' => 'categories',
),
//Select with AJAX search CPT
array(
'id' => 'example-select-4',
'type' => 'select',
'title' => 'Select CPT',
'placeholder' => 'Select a post',
'chosen' => true,
'ajax' => true,
'options' => 'posts',
'query_args' => array(
'post_type' => 'post_type_name',
),
),
//Select with AJAX search CPT Categories
array(
'id' => 'example-select-5',
'type' => 'select',
'title' => 'Select with CPT categories',
'placeholder' => 'Select a category',
'chosen' => true,
'ajax' => true,
'options' => 'categories',
'query_args' => array(
'taxonomy' => 'your_taxonomy_name',
),
),
/* Available Options
* 'options' => 'pages',
* 'options' => 'posts',
* 'options' => 'categories',
* 'options' => 'tags',
* 'options' => 'menus',
* 'options' => 'users',
* 'options' => 'sidebars',
* 'options' => 'roles',
* 'options' => 'post_types',
*/