Problem: I have a M2M relationship set up using an intermediary post type. I would like to use PHP and the post relationships API to query get all related parent posts of a known child post.
Solution: Use this code as a template:
1
2
3
4
5
6
7
8
9
$artists= toolset_get_related_posts(
get_the_ID(), // get posts related to the current post (product)
'artiste-product', // relationship between the posts
'child', // get posts where product is the child in given relationship
10, 0, // pagination
array(), // no extra args needed here
'post_object', // return post objects
'parent'// return the related parent post(s) in this relationship