Skip Navigation

[Resolved] Conditional display of custom fields based on taxonomy doesn’t work anymore

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

Problem:
A custom field group is set to display only on posts with a certain taxonomy term assigned, but this has stopped working.

Solution:
This was a bug introduced in Types 3.2.5 which is resolved by updating Types and Access.

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

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+01:00)

This topic contains 8 replies, has 2 voices.

Last updated by maximilianD 5 years, 1 month ago.

Assisted by: Nigel.

Author
Posts
#1202842

I have grouped different custom fields based on different product categories and set a condition to only show the custom fields on products that are linked to a specific product category. This worked for a while, but I now saw, that it seems to be broken. Now all the custom fields show up on every product despite the product category that it is linked to.

#1202880

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Hi there

There were improvements to conditional output in the last update for Views, so that amongst other things it is now possible to insert wpv-conditional shortcodes using the GUI which include tests for taxonomies.

This produces shortcodes in a new format, like so:

[wpv-conditional if="( CONTAINS(#(status),'archived') )"]
This is archived
[/wpv-conditional]

Previously it was possible to manually create wpv-conditional shortcodes, but there were inconsistencies as to whether they worked with term names, slugs, or IDs.

It wasn't intended or expected to break existing sites with the changes.

On your site I took a look at the product template where I can see a text block with many conditions, such as

[wpv-conditional if="( has_term('luftfahrt', 'einsatzbereich',null) eq '1' )" ]
Luftfahrt
[/wpv-conditional]
[wpv-conditional if="( has_term('bos', 'einsatzbereich',null) eq '1' )" ]
BOS
[/wpv-conditional]

Is this the section and format that has stopped working?

I looked at some products on the front-end but they were not displaying these conditional messages (the condition failed).

Can you point me to an example of where this is not working?

#1203064
Bildschirmfoto 2019-02-20 um 12.08.34.png
Bildschirmfoto 2019-02-20 um 12.09.08.png
Bildschirmfoto 2019-02-20 um 12.09.37.png

Thanks for your quick feedback. I was only talking about the backend. On the page where you edit the product details.
The custom fields are suppose to show conditional to the product category that is checked.

The attached screenshots show the areas that i am talking about.

The Category "Lautsprecher" is checked, but the custom fields that are linked to different categories show up e.g. (Handapparate, Hand-Mikrofon-Lautsprecher, etc)

#1203830

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

OK, thanks for clarifying.

That is a variant of a known issue: https://toolset.com/errata/the-field-group-assigned-to-a-content-template-appears-in-all-post-types-edit-screens/

In your case the problem arises when assigning the field group to a taxonomy term rather than a template, but the effect is the same, and I have added details of your thread to the internal ticket.

I'm escalating this and will update you when I have further news.

#1203849

thank you, is there anyway to get a solution within the next 2 days. It is very urgent.
Maybe any of this information will help:

1. It was working a few weeks ago. I can't tell when it stopped working.
2. I have recently deleted some woocommerce related fields like Onsale status and one or two others.
3. I have changed the type of some custom fields.
4. What I find odd is, that when I go the the taxonomy page in the toolset menu, product categories don't show up as taxonomy. Is that normal?

Please let me know if any of this could be related to the problem, or if it just broke due to a recent toolset update.

#1203853

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

We will be producing hotfix releases for Types, Views and Forms early next week which bundle together fixes for various issues.

Keep an eye on the erratum I linked to, it may be that a patch is offered to fix the issue.

The issue is nothing you have done, it arises from the update to Types 3.2.5.

Right now the only "fix" would be to revert back to Types 3.2.4, but that also means downgrading Views and Forms if you are using those, because of code that is shared between them.

Previous versions are available from the changelog sections of the downloads page: toolset.com/account/downloads

#1203856

Thank you. I will wait for the update.

#1206109

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Hi there

We released updates to Types, Views, and Forms yesterday afternoon which should fix this, please update and let me know if you continue to have problems.

#1206482

My issue is resolved now. Thank you!

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