Skip Navigation

[Resolved] toolset_get_related_posts for intermediary posts

This support ticket is created 4 years, 6 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 3 replies, has 2 voices.

Last updated by Minesh 4 years, 6 months ago.

Assisted by: Minesh.

Author
Posts
#1704627
#1704963

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Do you mean that you have many-to-many relationship between post type X and Y and intermediary posttype XY.

Now, based on specific single ID of post type belongs to X, you want to fetch the intermediary posts belongs to specified post type X ID?

#1705145

yup

#1705215

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Yes - you can surely use the toolset_get_related_posts() function in that case.

Considering the many-to-many post relationship between post types Student and Subject with intermediary post type "'student-subject" to get related intermediary posts for single student as follows:

For example:

$parent_student_id = 1755;
$results  = toolset_get_related_posts(
                                     $parent_student_id,  // single parent post ID
                                    'student-subject',    /// intermediary post type slug
                                     'parent',
                                     100,
                                      0,
                                      array(),
                                     'post_object',
                                     'intermediary'   // returning the intermediary posts 
                                     );

More info:
=> https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_posts