Tell us what you are trying to do?
I am trying to insert field options of a 'select' field of CPT B from titles of CPT A. So far i have been able to get the options to show up on the front end. however on inspecting the specific post field of CPT B on the backend, the options are still empty.
How can I get the options to be saved into the database? So that they are available in the post field editor?
Thank you for your time!
An example of the codes as follows:
// fill Breed custom field select options dynamically
add_filter( 'wpt_field_options', 'func_fill_select_breeds', 10, 2);
function func_fill_select_breeds( $options, $title ){
switch( $title ){
case 'Breed':
$options = array();
$args = array(
'post_type' => 'breeds',
'post_status' => 'publish',
'numberposts' => -1,
);
$ps_array = get_posts( $args );
foreach ($ps_array as $post) {
$options[] = array(
'#value' => $post->ID,
'#title' => $post->post_title,);
}
break;
}
return $options;
}
Is there any documentation that you are following?
https://toolset.com/documentation/programmer-reference/types-api-filters/#wpt_field_options
Is there a similar example that we can see?
What is the link to your site?