Home › Forums › Backend Issues (wp-admin) › Moving values from repeater subfield into a field › Reply To: Moving values from repeater subfield into a field
Do all of these repeaters only have a single row?
The repeater and the top level field are not named the same in the database and they have different field key references because they are two different fields.
First, the only way you can safely move the values is if there is only a single row in the repeater with these 5 fields, which kinda kills the purpose of using a repeater. If there can be multiple rows then you’d need to loop over them all and concatenate all the values or you’d just loose them.
If this is the case you would need to create a function that
1) Get all of the posts
2) Loops over the repeater in each post
3) Gets the value from each sub field
4) Updates the corresponding field using update_field($field_key', $value, $post_id)
. You need to use the field key rather than the field name because the fields may not exist when you update them.
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!
CPT registration is coming to ACF! We demoed the new feature during the most recent session of ACF Chat Fridays. Check out the summary for the details. https://t.co/k2KQ3WWBAz
— Advanced Custom Fields (@wp_acf) March 7, 2023
© 2023 Advanced Custom Fields.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.