I have created a content template with custom fields with labels. I would like to only display the labels when the fields have a value.
hidden link
Hello,
I suggest you try with [wpv-conditional] shortcode to check the custom field values, then display what you want. See our document:
https://toolset.com/documentation/user-guides/views/conditional-html-output-in-views/checking-fields-and-other-elements-for-emptynon-empty-values/
Checking fields and other elements for Empty/Non-empty Values
Hi, Lou, I used a conditional output to hide the label when the field is empty but the label is still showing :(. I looked at this video.
hidden link
My field:
<label class="labels">Servo or Stnadard:</label>[types field='servo-or-standard'][/types]
My field with conditional output
[wpv-conditional if="( $(wpcf-servo-or-standard) eq '' )"]<label class="labels">Servo or Stnadard:</label>[types field='servo-or-standard'][/types][/wpv-conditional]
The problem you mentioned above is abnormal, there might be other cache problem in your website, please try these:
1) In case it is a compatibility problem, please deactivate all other plugins, and switch to wordpress default theme 2020, deactivate all custom PHP/JS code snippets, and test again
2) Also check if there is any PHP/JS error in your website:
https://toolset.com/documentation/programmer-reference/debugging-sites-built-with-toolset/
And in your case, you need to change the comparing from "eq" with "ne", for example:
[wpv-conditional if="( $(wpcf-servo-or-standard) ne '' )"]<label class="labels">Servo or Stnadard:</label>[types field='servo-or-standard'][/types][/wpv-conditional]
See the document I mentioned above:
https://toolset.com/documentation/user-guides/views/conditional-html-output-in-views/checking-fields-and-other-elements-for-emptynon-empty-values/
section "Test a field for non-empty value"
Hi, Lou, I hope you are well and thank you for the excellent support. The is was eq but it seems to inset the eq by default. Ne fixed the issue.
My issue is resolved now. Thank you!