Home › Forums › Backend Issues (wp-admin) › Convert repeater to single field › Reply To: Convert repeater to single field
Unfortunately, there really is not an easy way to do this, the only thing that I can do is to tell you what I would do given the same scenario.
1) I would not delete the repeater
2) I would create the new fields
3) I would create a filter (https://www.advancedcustomfields.com/resources/acf-load_value/) that runs when the value is loaded for the new fields. If the new field does not have a value (has never been set) then retrieve the corresponding value from the old field. This will work to automatically transfer the old values to the new field when a post is edited.
4) I would create and action (https://www.advancedcustomfields.com/resources/acf-save_post/). In this action I would delete the old fields from each post as it is updated using the new fields.
5) With #3 & #4 in place and working successfully I would create another filter (https://www.advancedcustomfields.com/resources/acf-prepare_field/) for the repeater to hide the old field (return false). This leaves the old fields and data in place and sill retrievable for #3 and for #6 (coming up)
6) Alter the template file(s) where the old values are used. First see if the new field has a value and if it does use the new field. If the new field does not have a value then to get the value from the old field and use it.
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!
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.