Tell us what you are trying to do?
I need to fill the dropdown for filter search with extra information, like post title and the post ID, etc.
Is there any documentation that you are following?
I try this hook but seen to not work with last version of toolset. Many posts using this code is from 2017.
**
* Dynamically populate 'Country' custom field
* Using 'country' custom post type
*/
add_filter( 'wpt_field_options', 'custom_country_field_options', 10, 3);
function custom_country_field_options( $options, $title, $type ){
echo "string";
die();
if ( 'Country' == $title ) {
$options = array( // Initial empty state option
array(
'#value' => '',
'#title' => '-- Select Country --'
)
);
// Get country posts
$args = array(
'post_type' => 'oferta',
'post_status' => 'published'
);
$country_posts = get_posts( $args );
foreach ($country_posts as $country){
// Update custom field options with countries
$options[] = array(
'#value' => $country->ID,
'#title' => $country->post_title
);
}
}
return $options;
}
Is there a similar example that we can see?
What is the link to your site?
Hi,
The filter hook "wpt_field_options" is working in the latest version of Toolset Views + Types plugin, but it works only for the custom select/radio field created by Types plugin.
According to your codes, I suggest you try with a custom select field "Country", and a post type "oferta", then debug your codes line by line, manually.
Since it is a custom PHP codes problem, if you still need assistance for it, please provide a test site with the same problem, also point out the problem page URL + view URL, and where I can edit your PHP codes, I need a live website to test and debug.