Problem:
The user has a select field with dynamic option values. The options of the field are generated using Toolset Types filter wpt_field_options. The generated options are the months of the last two years.
Inside a view, the field is not displayed anymore.
Solution:
It turns out that the values that are not displayed are not included in the values generated by the wpt_field_options filter. Toolset returns an empty value.
The solution is to use a custom shortcode that will return the row value from the database.
// The shortcode needs to be added in Toolset->Settings->Custom Code.
add_shortcode('meta', 'meta_fun');
function meta_fun($atts){
global $post;
$atts = shortcode_atts(array(
'field' => NULL,
), $atts);
extract($atts);
if( NULL === $field ) return;
// return "Voila";
return get_post_meta($post->ID, $field, true);
}
// How to use it inside the view
[meta field="wpcf-production-year-month"]
Relevant Documentation:
https://toolset.com/documentation/programmer-reference/types-api-filters/#wpt_field_options
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|---|---|---|---|---|---|---|
| 9:00 – 13:00 | 9:00 – 13:00 | 9:00 – 13:00 | 9:00 – 13:00 | - | - | 9:00 – 13:00 |
| 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | - | - | 14:00 – 18:00 |
Supporter timezone: Africa/Casablanca (GMT+01:00)
This topic contains 3 replies, has 2 voices.
Last updated by 4 years, 8 months ago.
Assisted by: Jamal.