Skip Navigation

[Resolved] Get ID of both parent & child from intermediary 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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/Karachi (GMT+05:00)

This topic contains 2 replies, has 2 voices.

Last updated by marcusB-3 1 year, 7 months ago.

Assisted by: Waqar.

Author
Posts
#2459843

Tell us what you are trying to do?

I am running a function upon submitting a form that edits custom fields on an intermediary post.

I would like to create an additional function to work with custom fields that exist in both the parent and the child of this relationship that runs when submitting the form.

I need to retrieve the post IDs of the parent and child on the intermediary post the function is running on. I am very clear on how to gather the parent and child ID on a one to many relationship, but this intermediary post issue is quite confusing.

So put simply, I need to know the proper code to get the parent ID and child ID of the current intermediary post.

thank you!

marc

#2460475

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Marc,

Thank you for contacting us and I'd be happy to assist.

You can use the "toolset_get_related_posts" function to get the related parent and the child posts from an intermediary post ID:
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_posts

Example to get the parent post ID:


$get_parent = toolset_get_related_posts( $intermediary_post_id, $relationship_slug, 'intermediary', 1, 0, array(), 'post_id', 'parent' );

Example to get the child post ID:


$get_child  = toolset_get_related_posts( $intermediary_post_id, $relationship_slug, 'intermediary', 1, 0, array(), 'post_id', 'child' );

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar

#2461169

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.