Hello,
I am using the following code to populate a select dropdown box on a CPT and it works fine when a choice is made and the post saved.
add_filter( 'wpt_field_options', 'func_dynamic_populate', 10, 3);
function func_dynamic_populate( $options, $title, $type ){
switch( $title ){
case 'People ID':
$options = array();
$args = array(
'post_type' => 'people', // change post type slug here if needed
'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;
}
However if I use the select box within a repeating group it doesn't save the choice made. Is there any code that I can add to the above to make it work within a repeating group?
Thanks in advance,
Adam
Hi, actually the wpt_field_options filter is no longer supported and is not expected to work with new features like Repeating Field Groups. Unfortunately there is not a good way to create dynamic field inputs in the current system. If you'd like to request an improvement to our API and filters that will allow you to create dynamic field inputs that work in repeating field groups, feel free to submit a ticket using the "Suggest an improvement" feature here in the forums. For now, the only way to manage these options is to manual management in wp-admin.