I am useing this to get select box options from custom post type , but its not working
add_filter( 'wpt_field_options', 'generate_agency_title', 10, 3);
function generate_agency_title( $options, $title, $type ){
switch( $title ){
// run this code only if the field name is projecten-title
case 'agency-name':
$options = array();
$args = array(
'numberposts' => -1,
'post_type' => 'agency', // replace with appropriate post type anme
'post_status' => 'publish');
// Queries all the published posts of post type projecten
$posts_array = get_posts( $args );
foreach ($posts_array as $post) {
$options[] = array(
'#value' => $post->post_title,
'#title' => $post->post_title,
);
}
break;
}
return $options;
}
Hi there,
Let's troubleshoot the issue with fetching select box options from the custom post type agency. Here are some steps to help resolve the issue:
Double-check the field title used in the switch case statement (agency-name) to ensure it matches exactly with the field title as it appears in the WordPress Toolset plugin.
Verify that the custom post type name used in the post_type argument of the get_posts() function (agency) matches the actual name of the custom post type.
Check this as a reference:
https://toolset.com/documentation/programmer-reference/types-api-filters/#wpt_field_options
Thanks.
here you can find my post type and custom fields . its still not working
Hi there,
I can take a look. I'd appreciate it if you could give me the URL/User/Pass of your WordPress dashboard after you make sure that you have a backup of your website.
It is absolutely important that you give us a guarantee that you have a backup so if something happens you will have a point of restore.
Make sure you set the next reply as private.
I also need the name of the Form and the page you used the form in.
And Also where did you add the custom code so I can check.
Thanks.