Skip Navigation

[Resolved] Conditional Output

This thread is resolved. Here is a description of the problem and solution.

Problem:
How to conditionally output a taxonomy only if there is a term assigned to the current post.

Solution:
It is not possible to insert such a condition directly from the GUI, it needs to be entered manually.

An example of such a condition—using a "status" taxonomy—is as follows:

[wpv-conditional if="('[wpv-post-taxonomy type='status' format='slug']' ne '')"]<p>Status: [wpv-post-taxonomy type="status"]</p>[/wpv-conditional]

Relevant Documentation:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/displaying-taxonomies-conditionally/#one

This support ticket is created 5 years, 4 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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 4 replies, has 2 voices.

Last updated by rolandP 5 years, 4 months ago.

Assisted by: Nigel.

Author
Posts
#1291773

Hi
I need hide some value in other category.

example
[wpv-conditional if="( NOT(CONTAINS(#(pa_wys-robocza-m),'null')) )"]
<tr>
<td class="colleft">Wys. robocza:</td>
<td class="colright">[wpv-post-taxonomy type="pa_wys-robocza-m"] M</td>
</tr>
[/wpv-conditional]

If value pa_wys-robocza-m is null hide <tr>.

#1291919

Nigel
Supporter

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

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

pa_wys-robozca-m is a custom taxonomy, and effectively the condition should check whether the post has any term assigned (i.e. not nothing), is that what you are aiming for?

#1293297

on this site I need hide them because they haven't value hidden link
Wys. Robocza:
Max udzwig:
waga:

on this site I show them
hidden link

#1293467

Nigel
Supporter

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

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

OK, so you only want to output a taxonomy if there is a term assigned from that taxonomy.

That specific case is described in the documentation here: https://toolset.com/documentation/user-guides/conditional-html-output-in-views/displaying-taxonomies-conditionally/#one

It's not possible to insert such a condition using the GUI, you will need to enter it manually. Here's an example from my own site where I test whether the "status" taxonomy has a term before outputting it:

[wpv-conditional if="('[wpv-post-taxonomy type='status' format='slug']' ne '')"]<p>Status: [wpv-post-taxonomy type="status"]</p>[/wpv-conditional]
#1295517

My issue is resolved now. Thank you!