Navigation überspringen

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

Dieser Thread wurde gelöst. Hier ist eine Beschreibung des Problems und der Lösung.

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 vor 3 Jahre, 4 Monaten. 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 -

Zeitzone des Unterstützers: Asia/Karachi (GMT+05:00)

Dieses Thema enthält 2 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von Darryl vor 3 Jahre, 4 Monaten.

Assistiert von: Waqar.

Author
Artikel
#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: versteckter 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.