Problem: I have 3 custom fields that I would like to show in a post. Some fields may not contain a value in all posts. I would like to display these field values inline, separated by a comma, but I don't want to show a comma at the end of the list and I don't want to show commas for empty items. How can I filter the content template so this displays correctly?
Solution: You could use PHP to filter the Content Template using the Views API filter wpv_filter_content_template_output, but it's not much simpler or cleaner. You could try a CSS-based solution with an nth-child or first-of-type pseudo selector controlling the :before content of each element.
Relevant Documentation:
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_content_template_output
https://stackoverflow.com/questions/27836769/comma-separated-spans-with-pure-css
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, 5 months ago.
Assisted by: Christian Cox.