I’ve found a bit of a bug and I’m not sure if this is a known issue or not, or even if the issue is causing the troubles that I am having.
As some background, I have a site with 4 different custom post types and a ridiculous number of custom taxonomies related to them. Some of which share the same term, so same term (wp_terms), but different taxonomies (wp_term_taxonomy).
One of the post types is setup so that the admin of the website will choose a category from one field group and then save it. Once saved and the page reloads, a second field group will load thanks to conditional logic based on post type and the taxonomy.
This works fine. However, there is a taxonomy field in the second field group (set up as checkboxes) that when selected, causes the field group to disappear after a brief delay. (I can email a link to a screen recording if required)
I also looked at the conditional logic for showing the field group and this is where I think the bug is… or could be. The conditional logic is saving reference to the term, as opposed to the term_taxonomy. So upon checking the field group settings, the conditional logic is pointing to the last instance of the term in the dropdown.
So I’m not sure if the two are related, but to me the “Post Taxonomy” conditional logic seems to be saving reference to the wrong thing at the very least.
Any thoughts? I realise this description might be all over the place, but I am happy to give any more info that I can.
Also, thank you for creating this plugin, I definitely couldn’t have built the last few sites as well as I have without it.
Thanks for the info. The issue here is that upon clicking a taxonomy term, ACF fires an AJAX request to find field groups based on the current post.
For some reason, it seems that the data being posted is not correct and causing the wrong field groups to be returned. This is causing the field group to hide.
Can you provide a login account for me to test?
Looking at the edit screen, I can’t work out why the second metabox (Product – Filters – Paper) appears in the first place.
How do you set the
kw_brand_category taxonomy term for this post?
Only after this term is set, is the second metabox allowed to show.
I’m not sure if this is related, but when you setup conditional logic to display based on a certain taxonomy, you’re only storing reference to the
term_id, instead of the
term_taxonomy_id. This surely causes issues if there are terms that are repeated across taxonomies?
Array ( [param] => taxonomy [operator] => == [value] => 27 // term_id [order_no] => 1 [group_no] => 2 )
Thanks for the info.
I think I have figured out the issue.
because you are using a select field to manually set the taxonomy, ACF does not recognize this selected value in the JS.
Then, when you make any change to a taxonomy, ACF’s JS loads up all the selected taxonomy terms and does it’s AJAX request to find metaboxes based on the new location rule data.
ACF does not recognize your select field as a taxonomy term, so it doesn’t include it in the AJAX request. That is why ACF deos not return the correct field groups and your origional group disappears.
To solve this, please change your custom select field to a taxonomy field so that ACF can recognize it!
Hope that helps.
The topic ‘Custom Taxonomies and Conditional Logic’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
© 2023 Advanced Custom Fields.