Skip Navigation

[Resolved] Adding multiple relationship filters to a view

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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Hong_Kong (GMT+08:00)

This topic contains 3 replies, has 2 voices.

Last updated by Luo Yang 1 year, 6 months ago.

Assisted by: Luo Yang.

Author
Posts
#2614357

Tell us what you are trying to do?
I have a custom post type called Special Collections, which has a relationship connection to my custom post type of Departments. I am trying to create a view that shows all Special Collections with a relationship to any of 5 different departments. I know how to create a view that shows Special Collections related to a single department, but it does not appear that I am able to select more than one Department to display in my query filters.

I am following documentation here: https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/how-to-migrate-your-site-to-new-post-relationships/#advanced-example
but this example is code based and I am looking for a way to do this using the block editor.

#2614915

Hello,

In your case, it needs nested post views, for example:
1) Parent department post view:
- Query department posts
- Filter by:
Include only posts with the following IDs: 123, 456, 789
- In view's loop, display below child post view

2) Child post view:
- Query "Special Collection" posts
- Filter by:
post type relationship between "Special Collections" and "Departments"
- In view's loop, display Special Collection information

#2616237
nested.JPG

When I attempt to do this, I get an error message that states 'nested views are not supported.'

#2616311

You need to setup the child post view with legacy editor, see our document:
https://toolset.com/course-lesson/enabling-legacy-version-of-toolset-views/

See below sandbox website:
Login URL: hidden link

1) Child Special Collection view:
hidden link
- Query Special Collection posts
- filter by:
Select posts in a departments Special Collections relationship that are a related to the current post in the loop

2) Single department content template:
hidden link
Display a view block:
- Query department posts
- enable option "Don't include the current page in the query result"
- Sort by "Random order"
- ITEMS TO DISPLAY: 5
- In view's loop, display a view block, and choose above child post view "Child Special Collection view"

Test it in frontend:
hidden link
It works fine.

For your reference.