Support

Account

Home Forums General Issues Two taxonomy fields with the same custom taxonomy

Solving

Two taxonomy fields with the same custom taxonomy

  • Hi,

    2 Taxonomy fields in my form are populated by the same custom taxonomy.
    It seems when i choose one , it saves the same value for the 2 fields.
    I want each one has its own value, i don’t know how to do…
    thanks for help

  • Turn off save and load terms on both fields.

  • but they must be synced to the custom taxonomy to do searches

  • It cannot be done this way using save and load terms on ACF fields. You will need to create an acf/save_post filter https://www.advancedcustomfields.com/resources/acf-save_post/, get the values from the two fields and use wp_set_object_terms() https://codex.wordpress.org/Function_Reference/wp_set_object_terms to update them yourself.

    ACF uses false for $append, if it did not then it could never remove a term when one is deleted from the field.

  • so, imagine my CPT is MOVIE.
    My custom taxonomy MOVIE GENRE = (Animation, Horror, Action…)

    i have 2 Taxonomy fields i my form : Genre#1, Genre#1
    Both are linked and populated with MOVIE GENRE.

    I choose Animation for Genre#1 and Action for Genre#2.

    I display this data in admin columns, and so i have Animation,Action in column Genre#1 and Animation,Action in column Genre#2, instead of Genre#1:Animation Genre#2:Action this is the problem !!

    I know wp_set_object_terms() and do you think i have no other choice to use it ?
    thanks

  • There isn’t any way in ACF to have to taxonomy fields using the same taxonomy that work independently with using save and load terms. The only option for doing this is what I suggested above. acf/save_post filter and setting the post’s terms yourself.

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

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.