Skip Navigation

[Resolved] Is this specific Relationship view possible, if so how? (types/views beta)

This support ticket is created 6 years, 4 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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+01:00)

This topic contains 2 replies, has 2 voices.

Last updated by Taiko 6 years, 4 months ago.

Assisted by: Nigel.

Author
Posts
#600826

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.

#601041

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Hi there

Nearly.

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.

#601091

Hi Nigel,

Yeah, the duplicates makes this approach not really a viable option.
Indeed, hopefully with a future update.

Thanks for the support.

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