Home Forums General Issues Populate / Edit Taxonomy Fields on an Edit Screen


Populate / Edit Taxonomy Fields on an Edit Screen

  • Hey there —

    I have a CPT called “Abstracts.”

    I set up two custom taxonomies — “Abstract Author” and “Abstract Company.”

    I’ve added some ACF fields to those taxonomies — name, address, etc.

    Here’s what I’m trying to accomplish:

    — The user chooses or adds a taxonomy term for the post
    — After choosing the taxonomy term, the ACF fields associated with that term appear on the same edit screen.
    — The user can then edit or newly fill out those field
    — When you publish the post, those ACF fields will save back to the terms assigned.

    Basically, I’m trying to avoid adding a taxonomy term, then saving, then clicking over to the term, then editing the ACF fields, then saving that. I’d like to have it all in one place.

    Does this seem like it’s even possible? Could this be done with a front end form maybe?

  • Yes, this is possible, but complicated, and I don’t have any specific code to share.

    For the first bit, populating fields when a term is selected, you need to write JavaScript that makes an ajax request to get and populate the fields when the tax field changes. There are some examples of doing similar things here (some work, some do not)

    You’ll also need to create an acf/prepare_field filter that will load these fields’ values with current values from the term when a post is edited to reflect any changes made from another post.

    For the second part you need to create an acf/save_post filter that takes the submitted values and updated the term.

  • Thanks. Yes, I figured that it was going to be slightly complicated but this is a good start.

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

You must be logged in to reply to this topic.