Skip Navigation

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

Este hilo está resuelto. Aquí tiene una descripción del problema y la solución.

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 hace 2 años, 8 meses. 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.

Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.

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)

Este tema contiene 2 respuestas, tiene 2 mensajes.

Última actualización por Darryl hace 2 años, 8 meses.

Asistido por: Waqar.

Autor
Mensajes
#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: enlace oculto )


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