I’m having a little trouble making ACF behave like I think that it should.
I am making a personal library site and I have a custom taxonomy called ‘series’. I’m trying to record a book’s series and position within that series. So far, that works fine. Where it gets tricky is when a book belongs to more than one series. Using a taxonomy field as a sub field in a repeater is creating all sorts of issues.
The example book is Isaac Asimov’s Pebble in the Sky. It is the 8th book in the Foundation series and the 3rd book within the Empire series. With a repeater that records series name (taxonomy subfield) and series position (number sub field), as long as I do not check “Load & Save Terms to Post” this works but does not assign the taxonomy terms to my post, which I want. If I DO check that, it seems only one taxonomy term is saved and my repeater records one row of Foundation 8 and one row of Foundation 3. No.
Why is this? Is there something that can be done to get the terms saved to a post AND allow me to have more than one?
edit: This behavior is still present in the V5 beta 🙁
This problem will still exist in the new version. The reason is that as each field is save it updates all of the terms assigned in each field, and removes the ones not there. It’s the way that taxonomies and terms works when updating them in code. This is covered in https://codex.wordpress.org/Function_Reference/wp_set_post_terms because the $append argument to the function is set to false in ACF and in 99% of cases this is the way people would want this to work.
What you will need to do if you want it to work differently is create an acf/save_post filter https://www.advancedcustomfields.com/resources/acfsave_post/, use a priority of 20 so it runs after acf. In your filter you will need to get the values from the repeater field and update the terms again yourself.
This is an older topic, but I thought this information might help someone else looking for the same thing.
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users