Support

Account

Home Forums ACF PRO Add new term + term meta on Post screen Reply To: Add new term + term meta on Post screen

  • There is a plugin that will let you do this for relationship fields, but I cannot find anything available to allow doing this with terms.

    This is not something that can be done in ACF without a lot of work. For example, if you wanted to do the modal thing for editing.

    If I had to do this what I would probably do is the following…. I don’t have code and there would be a lot of it, so I can’t really provide it without actually building this.

    1) I would create a fields, I would probably use a “Group” field. This field would be conditional on the taxonomy field having any value. Alternately you could have an “update the term” true false field and and make the group conditional on this field.

    2) In the group field I would add the fields that need to be updated in the term. I would make these fields required, but this would be more difficult because you wouldn’t know if the term is new or not, if the term already has these values you’d probably not want to update them, but more on this later.

    3) I would create an acf/prepare_field filter. In this filter I would get the value from the taxonomy field and I would use this to get the values from the term and populate the group field with these values if they exist.

    3) I would then add an acf/save_post filter. In this filter I would get the value from the taxonomy field and the fields that need to be updated in the term and I would update the term with these values. After updating the term I would delete the values from group field values from the post, they will be populated again when the post is reloaded (see #3)

    4) I would create custom JavaScript that would detect a change in the taxonomy field, make an AJAX request and populate the values of the group field based on the term selected. I have some examples of this here, but nothing related to doing these things based on a taxonomy field https://github.com/Hube2/acf-dynamic-ajax-select-example