Skip Navigation

[Resolved] Move existing post field inside Repeatable group

This thread is resolved. Here is a description of the problem and solution.

Problem: I would like to move an existing custom field that is already saved in several posts, into a Repeating Field Group (RFG) applied to the same post type.

Solution: Migrating existing field values would require complex custom code. Dragging the field in the field editor screen would not delete any data from the database, but it would not migrate the values correctly either.

This support ticket is created 6 years, 7 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 1 reply, has 2 voices.

Last updated by Christian Cox 6 years, 7 months ago.

Assisted by: Christian Cox.

Author
Posts
#918335
Screen Shot 2018-06-27 at 14.48.49.png

Is there a way to migrate data from an existing Post Field* to a new field inside Repeatable Group?

If I just move it inside the repeatable group like in the screenshot the Post URL won't be shown as a new Repeatable Group in every individual post.

* Created in the past and already contains data from multiple posts

#918386

Moving the field in the custom field editor will not affect the existing field values stored in the database. The existing field values will remain stored with the parent post. When the parent post is edited in wp-admin, it will be possible to set new field values in each Repeating Field Group (RFG), but there's not an easy way to migrate these field values from wp-admin. It would require complex custom code that loops over the parent posts, loops over their child RFGs, and manipulates the necessary postmeta fields' values. RFGs are the 'child' role in a parent / child relationship with the current post, where the relationship slug is the same as the RFG slug. If you're a PHP developer, you may find our post relationships API documentation helpful:
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_posts