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 8 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.

Aucun de nos assistants n'est disponible aujourd'hui sur le forum Jeu d'outils. Veuillez créer un ticket, et nous nous le traiterons dès notre prochaine connexion. Merci de votre compréhension.

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)

Ce sujet contient 2 réponses, a 2 voix.

Dernière mise à jour par Darryl Il y a 2 années et 8 mois.

Assisté par: 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

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: lien caché )


( 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.