Skip Navigation

[Resolved] Display Label in Content Template Only When Field Has Value

This support ticket is created 4 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.

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: Asia/Hong_Kong (GMT+08:00)

This topic contains 5 replies, has 2 voices.

Last updated by richardB-17 4 years, 11 months ago.

Assisted by: Luo Yang.

Author
Posts
#1512789

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

#1513933

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

#1514599
image4.png

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]

#1515655

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"

#1516391

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.

#1516393

My issue is resolved now. Thank you!