Skip Navigation

[Resolved] Custom filters with relations

This thread is resolved. Here is a description of the problem and solution.

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.

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 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Sao_Paulo (GMT-03:00)

This topic contains 7 replies, has 2 voices.

Last updated by Mateus Getulio 1 year, 4 months ago.

Assisted by: Mateus Getulio.

Author
Posts
#2623007

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.

#2623047

Mateus Getulio
Supporter

Languages: English (English )

Timezone: America/Sao_Paulo (GMT-03:00)

Hi there,

Thanks for your contact!

Answering your questions:

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

Yes, it is possible to achieve that behavior, but I'm not sure how it's going to work in your setup, we would need to check it better (backend and frontend). For example, you could select a relationship filter in your custom search, and it should be enough. Please check our doc related: https://toolset.com/course-lesson/creating-a-custom-search/

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.

I'm not sure if I understood it correctly, but if you mean to limit the visibility of the owners, you can use our Access plugin: https://toolset.com/home/types-access/

Please let me know if these explanation are clear to you and solve the question. Thanks!

Regards,
Mateus.

#2623105

Hi Mateus, thank you for your reply.
1: yes, creating custom search is quite familiar to me, but for some reason my setup now doesn't work and I can't figure out why. Because the site is under construction it can be viewed only when logged in.
2: yes, I'm using access to show the custom posts only to their author. I'm using custom posts with relations because of this. If one could "own" taxonomies, I would use those instead of related custom posts.

Would you like to take a look at the structure and tell my what is wrong in my search filters?
Regards
Katja

#2623275

Mateus Getulio
Supporter

Languages: English (English )

Timezone: America/Sao_Paulo (GMT-03:00)

Hi Katja,

Thanks for your reply.

Please show us where exactly we can check this issue in the website. Also, I would like to request temporary access (wp-admin and FTP) to your site to take better look at the issue. You will find the needed fields for this below the comment area when you log in to leave your next reply. The information you will enter is private which means only you and I can see and have access to it.

Our Debugging Procedures

I will be checking various settings in the backend to see if the issue can be resolved. Although I won't be making changes that affect the live site, it is still good practice to backup the site before providing us access. In the event that we do need to debug the site further, I will duplicate the site and work in a separate, local development environment to avoid affecting the live site.

Privacy and Security Policy

We have strict policies regarding privacy and access to your information. Please see:
https://toolset.com/privacy-policy-and-gdpr-compliance/#data-shared-with-our-support
**IMPORTANT**

- Please make a backup of site files and database before providing us access.
- If you do not see the wp-admin/FTP fields this means your post & website login details will be made PUBLIC. DO NOT post your website details unless you see the required wp-admin/FTP fields. If you do not, please ask me to enable the private box. The private box looks like this: hidden link

Please, let me know if you need any additional details. Have a nice day.

#2623779

Mateus Getulio
Supporter

Languages: English (English )

Timezone: America/Sao_Paulo (GMT-03:00)

Hello again,

Thank you for providing the credentials.

I have double-checked the problem, but so far I haven't been able to find a fix. I asked my colleagues to take a look to see if there's anything I'm missing.

I'll come back here as soon as one of them answers me (which shouldn't take long). Thank you in advance for your patience!

Regards,
Mateus.

#2624079

Mateus Getulio
Supporter

Languages: English (English )

Timezone: America/Sao_Paulo (GMT-03:00)

Hi there,

Thanks for your patience.

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: hidden link

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. Please take a look and let us know if you're able to solve it now.

Thank you

#2624509

Hello Mateus,

Well this nested relations is excactly what I first tried to make work. But I couldn't make it work before. I had to try different combination and this way it finally works:
- content selection: the things/asiat
- custom search filter: post relationship: huonekalut/furniture (thing's parent)
- next filter: huoneet/room (furniture's parent)
- next filter: sijainnit/location (room's parent)

My initial problem was, it didn't give me the possiblity to make this way first (after choosing the furniture, it said something about no more ancestors).

I now created first the list of locations and chose the relations from top to bottom. But that didn't give the usability I need in frontend. After I changed the list back to things, I suddenly could change the filters the way I want. So something fishy there was, but now it works, so thank you very much!

EDIT: I tried to change the issue to solved but can't, so you can do it. Thank you for your help!

#2624767

Mateus Getulio
Supporter

Languages: English (English )

Timezone: America/Sao_Paulo (GMT-03:00)

Hello there,

Thanks for your reply.

Glad that you were able to resolve this. In this case, I hope we are good to close here. Feel free to contact us any time if you need assistance with our products.

Thank you, have a great one!