Skip Navigation

[Resolved] I want to display a taxonomy only if at least one of the terms has been selected

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

Problem:

A user reported that he is trying to use a conditional block to show the taxonomy information, only if at least one of the terms is selected.

Solution:

Shared the example syntax of the empty check conditional statement for the taxonomy.

Relevant Documentation:

n/a

This support ticket is created 2 years, 9 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/Karachi (GMT+05:00)

This topic contains 2 replies, has 2 voices.

Last updated by Darryl 2 years, 9 months ago.

Assisted by: Waqar.

Author
Posts
#2318875
8f4a65b4-9bc9-4276-8524-493b2528422b[1].jpeg

I'm trying to use a conditional block to display content only if at least one of the taxonomy terms has been selected.

In the conditional parameters I'm selecting: Post Data>Current Post>Post Taxonomies>My Taxonomy
Then testing against an empty value.
When I'm done it says "Incomplete condition" over on the right.

#2319073

Hi,

Thank you for contacting us and I'd be happy to assist.

From the conditional block's settings, you can switch to the "Advanced Editor" and the conditional statement will look like this:
( screenshot: hidden link )


( empty( '[wpv-post-taxonomy type="book-category" format="slug" ]') ) 

Note: Please replace "book-category" with your taxonomy slug.

When you'll save the conditional block this way, it won't show the "Incomplete condition" message.

regards,
Waqar

#2320035

I had to add a NOT to the beginning but that really helped me with the syntax, which I always struggle with. Thanks a bunch.

My final result was

NOT ( empty( '[wpv-post-taxonomy type="book-category" format="slug" ]') )

which displays content when any term from that taxonomy is selected.