Support

Account

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.