There's a feature I'm always surprised that your plugin doesn't offer.
I often come across the scenario where I'd love to be able to have a dropdown list on the "parent" custom post type where I could select which "child" is relevent.
e.g. If I had an events and a speaker custom post type – I'd want to have a dropdown on the edit events page where I can select the speaker from a list.
If you could do this by dragging a new custom field into a custom field group where you could configure which custom post type or custom taxonomy to list posts from that would be ideal.
Types has a filter that enables this feature 'wpt_field_options'.
Lets say that you had created a custom group and on that added a custom field of type select with the name 'my select field'.
Now you want to populate that select wherever it is displayed with all the posts that are published.
Just add the following to your functions.php file
//dynamically populate select field from Types
add_filter( 'wpt_field_options', 'prefix_custom_options', 10, 3);
function prefix_custom_options( $options, $title, $type ){
switch( $title ){
case 'my-select-field':
$options = array();
$args = array(
'post_type' => 'post',
'post_status' => 'publish');
$posts_array = get_posts( $args );
foreach ($posts_array as $post) {
$options[] = array(
'#value' => $post->ID,
'#title' => $post->post_title,
);
}
break;
}
return $options;
}
Would this resolve your issue?
Hi Ana
Thanks so much for this - Ill definitely give this a go.
How would I go about using the above if I wanted the dropdown to be a repeatable field?
Dan
Currently we do not have the option to allow a custom filed of type select to have multiple-instances, thus making it into a repeatable-field.