This support ticket is created 4 years, 3 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.
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.
Hi I was wondering if you could help. I have a CPT called Departments which is realated in a 1-2 many relationship with a CPT called Services (a Department can have many Services)
I think this should be straightforward but for some reason i am having trouble getting it to work. What I want to do is on the Service pages show a list of all the other Services that are related to the same Departemt.
Note - I am using views not blocks.
Screenshot 1 shows my setup and screenshot 2 shows what I am trying to achive.
Good job you are using Views, it is pretty difficult to do with Blocks right now, although we should hopefully be able to improve on this in the next dev cycle.
So the starting context is a child post (a service).
You will create a View to list service posts. You need to add a Query Filter to say that it should show service posts related to some department.
Which department? That's where you are stuck, I guess.
Choose to pass the parent ID as a shortcode attribute. You can see an example from my test web site (with Projects << Tasks relationship) in the screenshot. It suggests 'wpvrelatedto' as the attribute, but you can change that if you want.
Be sure that the default option to exclude the current page from results is checked (so you don't repeat the current service).
Now insert the View via shortcode in your service template. Edit the shortcode to add the wpvrelatedto attribute, using the wpv-post-id shortcode to provide the value. If you use the Fields and Views button to insert the shortcode you can use the Post Content tab to specify that the ID you want is not that of the current post (the service), but that of the parent department, which will add an item attribute to the wpv-post-id shortcode, so that you end up with something like this (based on my relationship):