Skip Navigation

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

Ce fil est résolu. Voici une description du problème et la solution proposée.

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 Il y a 2 années et 1 mois. 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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 réponses, has 2 voix.

Last updated by Darryl Il y a 2 années et 1 mois.

Assisted by: Waqar.

Auteur
Publications
#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

Waqar
Supporter

Languages: Anglais (English )

Timezone: Asia/Karachi (GMT+05:00)

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.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.