Problem: I would like to use a conditional to test if a numeric custom field value is empty or greater than zero. If so, I would like to display the value. If not, I would like to display nothing.
Solution: You could use "AND" in the comparison to test both ne '' and ne '0', like so:
{!{wpv-conditional if="( ($(wpcf-listing-price) ne '' ) AND ($(wpcf-listing-price) ne '0' ))"}!}PRICE: [types field='listing-price' format='FIELD_VALUE'][/types]{!{/wpv-conditional}!}
Or testing if the value is greater than zero might be a simpler solution:
{!{wpv-conditional if="( $(wpcf-listing-price) gt 0 )"}!}PRICE: [types field='listing-price' format='FIELD_VALUE'][/types]{!{/wpv-conditional}!}
Relevant Documentation:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/
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 |
---|---|---|---|---|---|---|
8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | - | - |
13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | - | - |
Supporter timezone: America/New_York (GMT-04:00)
This topic contains 5 replies, has 3 voices.
Last updated by 5 years ago.
Assisted by: Christian Cox.