Problem:
I'm creating sort of inventory service where visitor can create houses, rooms, furnitures and things. The *things* are what visitor searches.
- House can have multiple rooms (one to many rel)
- Room can have multiple furnitures (one to many)
- Furniture can have multiple *things* inside it (one to many)
Now I would like to have also custom search filters so that when house is selected, all the *things* inside that house are listed. I haven't been able to do it - because of nested relations I guess..?
So I also created extra relations:
- House can have multiple *things* (one to many)
- Room can have multiple *things* (one to many)
This is a bit unconvenient for the user IMHO, but anyway, if one must choose also the room and the house in the form (when creating *things*), then so be it. But that dosn't give the expected results anyway. The houses and rooms filters don't show any results though the relations are there.
So my questions are:
1. Is there a way to have this kind of experience for the visitor:
- default shows all the things
- clicking either house/room/furniture selector the list updates accordingly
2. Is this doable with relations and preferably nested relations? The houses, rooms, furnitures and things must be "authored" so that only their own are visible when logged in. The taxonomies still can't be owned I suppose.
Solution:
It seems that you can achieve that behavior without adding extra relationships (things and rooms + things and houses). All you need to do is to nest the relationships when creating the first custom search filter, like this: https://snipboard.io/PJhi2M.jpg
Please check our doc related: https://toolset.com/course-lesson/creating-a-custom-search/#how-to-search-by-post-relationships
You can also use our 'Real Estate' website as a reference for this feature:
- https://toolset.com/course/wordpress-real-estate-sites/
- https://discover-wp.com/site-types/cb-properties-real-estate-site
The page 'Find a property' has this type of relationships (one-to-many) nested in one custom search filter.