Skip Navigation

[Resolved] conditionals using older eq and ne comparisons for categories don't work anymore

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.

This topic contains 4 replies, has 2 voices.

Last updated by scottL-3 1 month, 1 week ago.

Assigned support staff: Minesh.

Author
Posts
#1776355

I am trying to:
Show related products with alternate views based on product category. I was using an older format for the conditional like this:
[wpv-conditional if="( '[wpv-post-taxonomy type='product_cat' format='slug']' eq 'thin-stone-veneer' )"]

Link to a page where the issue can be seen:
Can't be seen because I fixed it but not sure if it is in other templates or layouts and need to know if it will be fixed or if I need to closely examine lots of templates on lots of sites to see if I need to update it there too.

I expected to see:
The proper View that met the condition.

Instead, I got:
The incorrect view because the conditional test failed.

I changed the layout to use this conditional instead:

[wpv-conditional if="( CONTAINS(#(product_cat),'thin-stone-veneer') )"]

and now it works correctly but as I said above, I need to know if this will be fixed or if I need to search through all my templates and layouts on lots of sites looking for the same issue and fixing it.

#1776783

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Both syntax are correct for the conditional display of the category.

If you are using the following syntax:

[wpv-conditional if="( '[wpv-post-taxonomy type='product_cat' format='slug']' eq 'thin-stone-veneer' )"]

- You will require to make sure that only one term assigned to your post. If you assign multiple terms then it will not work.

If you want to display conditional based on specific term out of multiple term assigned then you will require to use the following syntax.

[wpv-conditional if="( CONTAINS(#(product_cat),'thin-stone-veneer') )"]
#1777373

Thanks Minesh. It seems like the 'eq' method used to work even if there was more than one term assigned. These products have always been in more than one term and it used to work. I'll change to using contains to be safe.

You can close this ticket as resolved. If 'eq' used to work even with more than one term and now it doesn't, I'd appreciate knowing that for sure.

#1778199

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Great.

It could be your assumption but "eq" will work definitely but you will require to adjust your conditional like if your post have been assigned two terms, you will require to compare with two terms.

As I suggested - you should convert your conditionals with CONTAINS() method, so it will be able to find term within multiple terms assigned.

You are welcome to mark resolve this ticket.

#1782023

Thanks for explaining the cause and guiding me to fix it.