select-posts(sample)

Display a single select drop down box containing existing posts. Custom post types are also supported.

Option Details & Parameters

Type: select-posts

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 post 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.
post_type string (Optional) The post_type of the posts to show. Can be used to show custom post types. Defaults to post
num int (Optional) The number of posts to show in the select box. Defaults to -1 (all posts)
post_status string (Optional) The post_status of the post to show in the select box. Value can be any status parameter in the codex. Defaults to any.
orderby string (Optional) The sorting field used to display the options in the select box. Value can be any post orderby value in the codex. Defaults to post_date
order string (Optional) The sorting order used to display the options in the select box. Value can either be asc or desc. Defaults to desc

Examples

Creating an option:

$panel->createOption( array(
'name' => 'Select a post',
'id' => 'my_post_option',
'type' => 'select-posts',
'desc' => 'This is an option'
) );

Creating an option for a custom post type:

$panel->createOption( array(
'name' => 'Select a post',
'id' => 'my_post_option',
'type' => 'select-posts',
'desc' => 'This is an option',
'post_type' => 'portfolio',
) );