Skip Navigation

[Geschlossen] wpf-if custom field has value, display it. If no value, hide it.

This support ticket is created vor 10 Jahre, 8 Monate. 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 1 Antwort, has 1 Stimme.

Last updated by Matthew vor 10 Jahre, 8 Monate.

Author
Artikel
#12193

I'm making an events calendar with events that last 1 day, and events that last multiple days.

To make this work with the output design, I've created two 'date' custom fields: "start-date" and "end-date"
Events that last only one day do not need an "end-date". Is there a way to output specific html only if "wpcf-end-date" has a value?

Here is the relevant part of my view template:

<div class="start-date">
<div class="start-month">[types field="start-date" style="text" format="M"][/types]</div>
<div class="start-day">[types field="start-date" style="text" format="j"][/types]</div>
</div>

<!-- Only show the following if wpcf-end-date has a value -->
<div class="end-date">
<div class="end-month">[types field="end-date" style="text" format="M"][/types]</div>
<div class="end-day">[types field="end-date" style="text" format="j"][/types]</div>
</div>
#12194

This worked:

<!-- Only show the following if wpcf-end-date has a value -->
[wpv-if end="wpcf-end-date" evaluate="$end > 0 "]

<div class="end-date">
  <div class="end-month">[types field="end-date" style="text" format="M"][/types]</div>
  <div class="end-day">[types field="end-date" style="text" format="j"][/types]</div>
</div>

[/wpv-if]

Das Thema „[Geschlossen] wpf-if custom field has value, display it. If no value, hide it.“ ist für neue Antworten geschlossen.