Skip Navigation

[Resolved] Check a Term in a conditional

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

Problem:
How can I check if a Post is assigned to any Taxonomy Term, even WooCoomerce Taxonomy Terms?

Solution:
Try this syntax:

[wpv-conditional if="( has_term('Term Name', 'taxonomy_slug', null) eq '1' )" ]
  
Yes, it's assigned
  
[/wpv-conditional]

You will need to register

has_term

as a function in Toolset > Settings > Front End Content > Functions inside conditional evaluations

Relevant Documentation:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/displaying-taxonomies-conditionally/

This support ticket is created 7 years, 8 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.

Our next available supporter will start replying to tickets in about 1.46 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 2 replies, has 2 voices.

Last updated by Armando 7 years, 8 months ago.

Assisted by: Beda.

Author
Posts
#427296

I am trying to: Set up conditional based on Woo Category

Hi, maybe i am not understanding how the conditionals work for Woo categories.

I have the following:

Category called: My Cat

Product with category selected.

My Conditional:

[wpv-conditional if="( woo_shop_display_is_categories() eq 'My Cat' )" ]This Matches [/wpv-conditional]

[wpv-conditional if="( woo_shop_display_is_categories() ne 'My Cat' )" ]This Matches NONE[/wpv-conditional]

Returns: This Matches NONE

It should return: This Matches

Thanks!!

#427347

Try this syntax:

[wpv-conditional if="( has_term('term-slug', 'product_cat', null) eq '1' )" ]
 
Yes, it's assigned
 
[/wpv-conditional]

https://toolset.com/documentation/user-guides/conditional-html-output-in-views/displaying-taxonomies-conditionally/

Let me know if that works, it did work locally.

You will need to register has_term as a function in Toolset > Settings > Front End Content > Functions inside conditional evaluations

#427710

I was thinking it was that, but can you tell me how woo_shop_display_is_categories() would be applied? I would assume that i would use this instead of has_term.

Thanks for your time

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