Problem: I have a one-to-many post relationship set up in Types. When I create a child post in wp-admin, I would like to automatically set the child post title based on the parent post's title, using save_post.
Solution: Use the post relationships API toolset_get_related_post to retrieve the parent post ID during the save_post hook when saving a child post. Then use WordPress API wp_update_post to set the child post title automatically.
$parent_id = toolset_get_related_post( $post_id, 'relationship-slug' );
Relevant Documentation:
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_post
https://developer.wordpress.org/reference/functions/wp_update_post/
https://developer.wordpress.org/reference/hooks/save_post/
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 4 replies, has 2 voices.
Last updated by 5 years ago.
Assisted by: Christian Cox.