Skip Navigation

[Resolved] Relationships: country – state – town

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

Problem: I would like to set up a hierarchical post relationship system using a series of one-to-many post relationships. Country should be parent of State, State should be parent of Town, Town should be parent of Ad. I would like to allow site visitors to use a custom search View to filter Ads. Everything is working okay but I want to give my clients the ability to add an Ad at the State level, and I want the custom search filter to be able to find these Ads as well.

Solution: There isn't a perfect solution to this problem, because only one post relationship custom search filter is supported. You can add another post relationship for State > Ads, to allow your clients to associate an Ad at the State level. Then you can create a second View of Ads filtered by post relationship, using the Ad > State post relationship, and set by a URL parameter. Place this second View of Ads on the same page as the original custom search View, but display only the results and no filters.

There are limitations to this approach, for example, AJAX updates are not supported.

This support ticket is created 4 years, 8 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.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Author
Posts
#1551029

Hi,
I am developing a site that has 4 post types:
- State
- Town
- District
- User ad

Most user ads have State>Town>Distritc, and I have no problem with this as I have created 3 relationships, and when I create a user ad he choose the District and all relationships are done:
- state > towns
- town > districts
- district > ads

My issue is that some User ads are posted in towns without district, and I don't know how to relate it to town, as I only have "district" on post type field

Then I would filter by those parent relationships

Thanks!

#1551389

Hello, I think you have several options. One option is to create a District post called "No District" for each Town that has no Districts. Then each User Ad must be posted to "No District" instead of posting directly to the Town.

Another option is to create a fourth post relationship: Town > Ads. That would allow your Users to associate an Ad directly with a Town. To some degree, the best solution depends on what you want to achieve. You mentioned filtering by post relationships, but I'm not sure what else you plan to use these posts for. Perhaps it would be helpful to set this up in a demo site so you can see how filtering would work with each possible solution?

I started a basic setup here with a few states, towns, districts and ads:
https://christiancox-22119-gswt-1.discover-wp.com/ad-search
If you register for a free account in our sandbox site https://discover-wp.com using the email address associated with your account here on https://toolset.com, I can send you an invitation to collaborate. You can see how things are set up in wp-admin, and we can explore pros and cons of any approach.

#1551431

Cool Christian, I am registered, what should I do now?

#1552157

Okay great, you should receive an invitation to join the site. Then you can look at the configurations for the Ad Search View here: https://christiancox-22119-gswt-1.discover-wp.com/wp-admin/admin.php?page=views-editor&view_id=3065

Would you like to try adding the 4th post relationship to this demo site? That would be a one-to-many between Towns and Ads. Then you can add some Ads and attach them directly to a Town, to see how that affects search results. Or maybe there is another scenario you would like to try first?

#1552251

Hmmm not received Christian, could you please send it again?

#1552717

Resent, but I have a suspicion this isn't working at the moment. I sent an invitation to a colleague and he did not receive it either. I'll have to ask my systems team to investigate. In the meantime, I have another way to collaborate but it will take some time for me to set it up. I'll update you shortly.

#1553315

Thanks Christian, that worked!!

#1553763

Please Christian let that sandbox open and this ticket, I still have one issue

#1553877

Okay I will keep that sandbox open for the moment. FYI the discover-wp.com site invitation issue has been resolved, so feel free to create sandbox sites of your own there.

#1554869

Solved! Thanks!

#1555177

Hey Christian,
I have created a new relationship Towns>ads (multilevel)

I must have done something wrong or I need to modify view

I have created an ad with town relationship instead of district hidden link and no result

For ads related to district it works hidden link

#1556493

Yes and that is a major limitation to this approach - only one post relationship ancestry is supported in the front-end search filters of a single View. If you want to support the district-ad relationship and its town and state ancestors, then it's not also possible to support the town-ad relationship and its state ancestors. Unfortunately with front-end search filters there is not a perfect workaround to this limitation. I added a second View that uses the Town-Ad post relationship filters and inserted that View using conditional HTML if at least a State is selected in the filters. So the workaround isn't perfect, unfortunately, but you can see how it would work here.

#1558283

Hi Christian,
I am not able to reset password. "Password reset is not allowed for this user"

Any idea?

Thanks

#1561799

It's a temporary login system. I can send you another login link: hidden link

#1563187

Thanks!