Skip Navigation

[Resolved] Bulk updating child posts by copying parent’s custom field

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

Problem:

On my post form to create the child I made it so two custom fields are copied from the parent to the child.

Is there any way I can bulk update those 3000 posts I created?

Solution:

There isn't such kind of built-in feature within Toolset plugins, you might consider custom codes, for example:

https://toolset.com/forums/topic/bulk-updating-child-posts-by-copying-parents-custom-field/#post-2234761

Relevant Documentation:

This support ticket is created 2 years, 11 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 2 replies, has 2 voices.

Last updated by ivanT-7 2 years, 11 months ago.

Assisted by: Luo Yang.

Author
Posts
#2234389
screenshot-www.climbingsardinia.com-2021.12.01-18_10_28.jpg

Hi there,

I have a parent post and its child.
On my post form to create the child I made it so two custom fields are copied from the parent to the child.

Now, after having created over 3000 child posts, I realized I need a third ​field to be copied from parent to child.

Is there any way I can bulk update those 3000 posts I created?

Thanks

#2234761

Hello,

There isn't such kind of built-in feature within Toolset plugins, you might consider custom codes, for example:
1) Get all child posts:
https://developer.wordpress.org/reference/functions/get_posts/
2) Use above child post ID to get related parent post information:
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_post
3) Use above parent post information to update child post custom field
https://developer.wordpress.org/reference/functions/update_post_meta/

#2238425

My issue is resolved now. Thank you!