Skip Navigation

[Resolved] Detecting one or more taxonomy terms and display the content conditionally

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

Problem:
Detecting one or more taxonomy terms and display the content conditionally

Solution:
You can use the shortcode [wpv-post-taxonomy] to get the taxonomy term attached to your post and use the [wpv-conditional] shortcode to display the content conditionally.

You can find the proposed solution in this case with the following reply:
https://toolset.com/forums/topic/detecting-one-or-more-taxonomy-terms/#post-1755303

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

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.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 3 replies, has 2 voices.

Last updated by edF-5 4 years, 3 months ago.

Assisted by: Minesh.

Author
Posts
#1754013

Hi there,

I'm trying to display a subheading and a list of taxonomy terms, but the subheading should only display if there is at least one taxonomy term. Can I use a conditional like the one below that checks if '' isn't in the list of terms?

  [wpv-conditional if="( NOT(CONTAINS(#(art-form),'')) )"]

Or do I need to implement a taxonomy count shortcode per the post below and use that in a conditional to check that the number is greater than zero?

https://toolset.com/forums/topic/taxonomy-count-for-a-post/

Or is there another way to check if a taxonomy is empty?

Thank you!

Saul

#1755303

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Can you please check the following example and try to resolve your issue:

For example:

[wpv-conditional if="('[wpv-post-taxonomy type='art-form' format='slug' ]' ne '' )"]
    // your content goes here
[/wpv-conditional]

More info:
=> https://toolset.com/documentation/user-guides/views/conditional-html-output-in-views/displaying-taxonomies-conditionally/#one

#1756907
snippet.png
output.png

Minesh,

Thanks for your response. I tried the snippet of code that you provided (see snippet.png), but it didn't work (see output.png). The objective is that the header, "Art Form," does not appear when the taxonomy is empty.

Saul

#1756985

Nevermind! I was apparently logged out of WordPress when applying the changes, even though there was no error message.

This is exactly what I needed. Thanks, Minesh!

Saul