I have two custom post types Services (hierarchical) and Cases (non-hierarchical). They have a many to many post relationship between them. Now I want to show on case posts, a list of links (title with link) to other case posts which are connected with (one or more of) the same service(s) as the current case post.
Example:
Case post 1 is connected to Service posts: 2, 7 & 8
Case post 2 is connected to Service posts: 1, 4 & 8
Case post 3 is connected to Service posts: 3, 6 & 7
Case post 4 is connected to Service posts: 3, 5 & 6
What I want to achieve:
Toolset to display a list of Case posts that are connected to the same Service post(s) as the current case post itself.
So with above connections, the view would display in Case post 1 titles with links to Case posts 2 & 3, since they all share the same connections with Service posts 7 & 8. But not Case post 4, since it doesn't share any of the same Service posts.
Case post 2 would only show case post 1, since it shares Service post 8. But doesn't share any Service posts connections with Case post 3 & 4.
Case post 3 would show Case posts 1 & 4.
And so on.
Yes, you can display the connected Cases (cases which are related to the same service), but I don't see how to eliminate duplicates. (This might become possible with custom coding in the future depending on how the Views API evolves.)
You can create a View to return the connected Services of the current Case. The View displays Services and has a post relationship Query Filter to show Services related to the current Case.
In the Loop Output section you don't display the Service, instead you nest a second View.
This second View does the opposite. It displays Cases connected to the current Service, using the same technique of a post relationship Query Filter. In the Loop Output section you display the case title (and in the no-items-found section you would leave that blank so nothing is output).
That lists the related cases, but where cases are connected by more than one service post they will be duplicated, and I don't see a way to eliminate that.