Dropdown Custom Post
The dropdown-custom-post
lets you add a select field where the options is custom post.

Parameters
Here are the parameters in adding dropdown-custom-post
.
a unique slug-like string to use as an id and also as index in saving data in database.
the label of the field.
the description of the field and display under the label.
the section where the field will be displayed.
the default value of the field.
Note: default value must be a post id.
determines the order of fields in section.
name of custom post type.
Note: post_type value must be existing custom post.
sets the order to ascending and descending.
Note: order only accept 'asc' and 'desc'.
Example
Yano::field( 'dropdown-custom-post', [
'id' => 'dropdowncustompostdb1',
'label' => 'Select Custom Post',
'description' => 'You can select a custom post in here.',
'section' => 'section_id',
'priority' => 1,
'post_type' => 'project',
'order' => 'asc'
] );
Example with default
value! note: default value must existing post id
.
Yano::field( 'dropdown-custom-post', [
'id' => 'dropdowncustompostdb1',
'label' => 'Select Custom Post',
'description' => 'You can select a custom post in here.',
'section' => 'section_id',
'default' => 100,
'priority' => 1,
'post_type' => 'project',
'order' => 'asc'
] );
Usage
The get_theme_mod()
function is recommended to retrieve data.
// Get the post by id
$post = get_post( get_theme_mod('dropdowncustompostdb1') );