Display a single select drop down box containing existing post categories. Taxonomies are alse supported.

Option Details & Parameters

Type: select-categories

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.
desc string The description to display together with this option.
default string (Optional) The default term / category ID for this option. Defaults to 0, nothing selected.
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.
orderby string (Optional) The sorting field used to display the options in the select box. Value can be any category orderby value in the codex. Defaults to name
order string (Optional) The sorting order used to display the options in the select box. Value can either be asc or desc. Defaults to asc
taxonomy string (Optional) The type of taxonomy / category to show in the select box. Defaults to category.
hide_empty boolean (Optional) If true, categories or taxonomies that do not have posts will not be shown. Defaults to false.
show_count boolean (Optional) If true, the number of posts in each category will be shown. Defaults to false.

Examples

Creating an option:

$panel->createOption( array(
'name' => 'Post Categories',
'id' => 'my_categories_option',
'type' => 'select-categories',
'desc' => 'This is an option'
) );

Creating a custom taxonomy select option:

$panel->createOption( array(
'name' => 'Post Categories',
'id' => 'my_categories_option',
'type' => 'select-categories',
'desc' => 'This is an option',
'taxonomy' => 'portfolio_category',
) );