Problem: I have a custom field that holds numeric data. When I display that custom field on the front-end of the site, I would like to use different colors to represent different ranges - values less than 1,000 show green font, values between 1,001 to 1,499 show in yellow, and values over 1,500 show red.
Solution: Use conditional HTML to display the field with different CSS classes based on the field value. For example:
[wpv-conditional if="( $(pond-1-tds-mg-l) lt '1001')"] <td class="your-green-class">[types field="pond-1-tds-mg-l" output="raw"][/types]</td> [/wpv-conditional] [wpv-conditional if="( $(pond-1-tds-mg-l) gte '1001' AND $(pond-1-tds-mg-l) lte '1500' )"] <td class="your-yellow-class">[types field="pond-1-tds-mg-l" output="raw"][/types]</td> [/wpv-conditional] [wpv-conditional if="( $(pond-1-tds-mg-l) gt '1500' )"] <td class="your-red-class">[types field="pond-1-tds-mg-l" output="raw"][/types]</td> [/wpv-conditional] ... and so on ...
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 2 replies, has 2 voices.
Last updated by 5 years, 9 months ago.
Assisted by: Christian Cox.