Skip Navigation

[Resolved] Hide empty field in loop item using Toolset Views

This support ticket is created 4 years, 3 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.

This topic contains 2 replies, has 2 voices.

Last updated by davidF-25 4 years, 3 months ago.

Author
Posts
#2188263

Tell us what you are trying to do? Hide empty field in loop item using Toolset Views (within Elementor page) when listing results. So I am displaying a search for an artist's album discography. Some of the albums do not have a "Conductor" so if that field is empty I do not want it to display the word "Conductor". In effect I want that <span> set to "display:none" when that field is empty. This is what I have in the loop:

[wpv-post-featured-image size='custom' width='300' height='300' crop='true' crop_horizontal='center' crop_vertical='center']
<div class="p-no-bottom-margin">
<h5 class="discography-title">[wpv-post-link]</h5>
<span class="gray-text">Artist: </span>[types field="artist"][/types]
<br><span class="gray-text">Additional Artists: </span>[types field="additional-artists"][/types]
<br><span class="gray-text">Conductor: </span>[types field="conductor"][/types]
<br><span class="gray-text">Label: </span>[types field="label"][/types]
<br>[types field="awards"][/types]
[types field="year-of-recording"][/types]
</div>

Is there any documentation that you are following? I followed documentation on how to create a loop item but do not see how to hide an empty field when displaying results.

Is there a similar example that we can see?

What is the link to your site? hidden link

#2188561

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

It looks like you are using the legacy editor with shortcodes for this, so you should see a "conditional output" button in the editor for inserting wpv-conditional shortcodes, which you can use to test whether a field has a value before outputting it (and the labels you add for it).

So, something like:

[wpv-conditional if="( $(wpcf-conductor) ne '' )"]<span class="gray-text">Conductor: </span>[types field="conductor"][/types][/wpv-conditional]
#2193089

My issue is resolved now. Thank you!