Problem: I am creating a post programmatically and I would like to link that post to another post using a post relationship.
Solution: Get the ID of the inserted post and use that in a toolset_connect_posts API call to connect the related posts.
//Create dynamic meeting room bookings add_action('cred_submit_complete_2147', 'meeting_booking_times_submit',10,2); function meeting_booking_times_submit($post_id, $form_data) { // Create post object $my_post = array( 'post_title' => 'dynamic', 'post_status' => 'publish', 'post_type' => 'booking-times', ); // Insert the post into the database $my_post_id = wp_insert_post( $my_post ); toolset_connect_posts( 'meeting-room-booking-meeting-room-booking-times', $post_id, $my_post_id ); }
Relevant Documentation:
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_connect_posts
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 2 replies, has 2 voices.
Last updated by 6 years, 4 months ago.
Assisted by: Christian Cox.