Support

Account

Home Forums Backend Issues (wp-admin) Custom Taxonomies and Conditional Logic

Solving

Custom Taxonomies and Conditional Logic

  • Hi,

    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.

    https://dl.dropboxusercontent.com/s/yc2qhsyxzamkk0c/2014-02-06%20at%203.18%20PM.png

    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)

    So, something seems amiss here. I tried looking at the javascript, but couldn’t quite figure it out, the disappearing field group gets a class of acf-hidden somehow.

    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.

    Cheers,

    Adrian.

  • This reply has been marked as private.
  • Hi @navitronic

    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?

    Thanks
    E

  • This reply has been marked as private.
  • Hi @navitronic

    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.

    Thanks
    E

  • This reply has been marked as private.
  • Any luck looking into this @elliot?

    I appreciate any help you can give.

  • Hi @elliot,

    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?

    Example:

    Array
    (
        [param] => taxonomy
        [operator] => ==
        [value] => 27 // term_id
        [order_no] => 1
        [group_no] => 2
    )

    Any thoughts?

    Cheers,

    Adrian.

  • Hi @navitronic

    Perhaps, when you say setup conditional logic, are you talking about the fiedl group location rules?

    I’ll be looking into this soon.

    Thanks
    E

  • Yes I am!

    I am drowning in different terms and names for things at this point in the project. ๐Ÿ™‚

    Thanks,

    Adrian.

  • Hi @navitronic

    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.

    Thanks
    E

Viewing 11 posts - 1 through 11 (of 11 total)

The topic ‘Custom Taxonomies and Conditional Logic’ is closed to new replies.