I’ve taken over a site where our client administrators are having to type the name of a taxomony term value into a text field on a custom post
Unfortunately it’s likely that they misspell or use other versions of the correct value
It should really be a drop down taxonomy term selector .. ie ACF field type = Taxonomy.
let’s say the field is called
subject and one of the values is “Book Shop”, sometimes this might be added as eg “Bookshop” or “Book-shop” and this is breaking some of the template logic
There are 1000+ existing records and I could do a search & replace, but again it should really just be a select box based on the Taxonomy Terms
however if I change the field type to correct this for future posts, it’s going to break the old posts
What would be the best strategy for fixing this going forward whilst dealing with the old data?
I don’t preferably want to change it to a normal select box with fixed values (so it stores as a single string in the db anyway as per https://support.advancedcustomfields.com/forums/topic/change-type-of-field-from-text-to-select/)…
Really I want it as a term value selector so any changes to the actual original Taxomomy Term are actually directly updated via the reference
However these field types are therefore incompatible.
Can I for instance create a new field with the same name (again let’s say
subject) but a different type… and then adjust my logic to account for the old text versions and the new term value reference versions? (and if old posts are updated it will overwrite with the new value?)
Or would it be better to create an entirely new field with a different name going forward and then adjust the template to check for both (prioritising the new one first)
thanks for any suggestions
Make a new taxonomy picker field with another name for example
subject_picker and adapt your logic if subject_picker field has a value do new logic if not do old logic.
and also maybe create terms by the old text inputs with a job. (looping all your posts, getting the field and creating term (wp_insert_term()).
then do a job and set value to all the old terms for the new subject_picker field.
yes that does seem to be the easiest solution.
I think it would maybe be possible to run a bulk script to update the value in-place with the term ID (ie in the same field) and then switch the field type after, but I’ll need to check exactly how the data is stored
any other ideas also welcome!
I kind-of agree with the idea of using a different field. My usual method of making changes like this is to.
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
Helping others is a great way to earn karma, gain badges and help ACF development!