Skip Navigation

[Resolved] Explanation of State/City search filters in real estate training site

This support ticket is created 5 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.

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)

This topic contains 16 replies, has 2 voices.

Last updated by Ben 5 years, 8 months ago.

Assisted by: Christian Cox.

Author
Posts
#1209680

Ben

Can someone explain to me how the State/City search filters are set up in your real estate training site?

I wanted to achieve something similar to this before but I didn't think it was possible.

#1209738
Screen Shot 2019-03-04 at 5.52.03 PM.png

You can create a free account at discover-wp.com to create your own demo site using the Real Estate reference site as a starting point. Then you can see exactly how this site's custom search is set up.
- There is a one-to-many relationship between custom post types States and Cities
- There is a one-to-many relationship between custom post types Cities and Houses
- The custom search View on the homepage allows you to search for Houses, and includes a Post Relationship filter which allows you to filter by multiple levels of one-to-many ancestry (State > City > House). Note that this hierarchical arrangement only works for "multi-generational" one-to-many relationships. The filter controls look like this:

<div class="row"> 
            	[wpv-control-post-relationship ancestors="state@state_city.parent>city@city_house.parent" url_param="wpv-relationship-filter"]
				<div class="form-group col-xs-6">
             	 <label>[wpml-string context="wpv-views"]State[/wpml-string]</label>
             	 [wpv-control-post-ancestor type="select" default_label="--State--" ancestor_type="state@state_city.parent"]
				</div>
            	<div class="form-group col-xs-6">
            	  <label>[wpml-string context="wpv-views"]City[/wpml-string]</label>
              	[wpv-control-post-ancestor type="select" default_label="--City--" ancestor_type="city@city_house.parent"]
				</div>
				[/wpv-control-post-relationship]
          	</div><!-- row -->

- You must select a State before a City because the custom search settings for this View are configured to "Show only available options for each input" as described here: https://toolset.com/documentation/user-guides/front-page-filters/advanced-settings-custom-search/
- I am attaching a screenshot of the Query Filter summary. Let me know if you have specific questions about that.

#1210168

Ben

Hello Christian, thank you for your response. I understand how this works now.

Why is it that this sort of option is only available for post relationships and not for taxonomies though?

I was under the impression, and still am, that taxonomies were the preferred "best practice" method for categorising custom posts. Why is it then that this sort of brilliant advanced feature is only available if the best practice hasn't been followed?

#1210257

The state and city filters are separate filters for separate post types. You can certainly create similar separate filters for separate taxonomies, but I think you're talking about separate dropdown filters for each level of hierarchy within the same taxonomy. That's not currently possible, and I don't know of a plan to implement it in the near future. If you'd like to see it implemented, I encourage you to submit a request here: https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/

That's the best way to get your opinion to key decision makers who will decide what features to add to the software.

#1210767

Ben

Yes you are correct Christian.

I have already submitted a new feature request for this, thank you.

If there was an ability to create relationships between different taxonomies, or link them in some way then I believe I would be able to achieve my desired result that way, but as this is not possible then I am not sure what to do now.

I want to be able to categorise CPTs in terms of Location. Taxonomies are the correct way to categorise posts using WordPress I believe, yet there is less functionality in this than using CPT with relationships, so I am unsure of how to proceed now, as this would be something very difficult to swap around once the site is fully populated.

Do you have any ideas or suggestions?

#1210771

What if you create 3 different taxonomies, one for each level of hierarchy? That would give you the ability to create 3 separate dropdown filters.

#1210775

Ben

Potentially! Thank you for the idea.

Although the taxonomy I would have to split up is one for locations, and I am concerned that a post could be assigned a country, and then a city that isn't actually in that country. This would all have to be based on the users personal geographical knowledge right?

There is no way I could "link" the taxonomies to ensure cities and countries remain correctly together?

#1210781

Yes, you are correct on both questions. There is no direct link between the taxonomies, and there is no enforcement of the correct organization of terms.

#1210783

Ben

If I split this taxonomy into different custom post types and link them with relationships, are there any limitations to what I will be able to do with this later on? As opposed to leaving it as a taxonomy.

#1210804

No more or less limitations than any other post type vs any other taxonomy as far as I know...I'm not sure I understand the question, though. Custom post types have a set of functionality and taxonomies have a different set of functionality. You can't assign taxonomy terms to other taxonomies, for example. You can't create many-to-many relationships between taxonomy terms. Taxonomies and custom post types are managed differently in wp-admin and Forms. We're really comparing apples and oranges here, so I'm not sure I know what you mean by limitations.

#1210872

Ben

Thank you for the reply Christian. Let me try and explain things better, it may help you with what I am trying to get at.

Currently I am categorising custom post types by location using a hierarchical taxonomy for countries and cities. These by nature will be large due to how many countries and cities exist in the world. However I have come across some serious limitations in terms of the ability for these to be used on the front end as filters due to the lack of ability to split a taxonomy into different drop downs or each level, and the absence of a way to search through dropdowns. These are the issues I brought up to you on my other thread. Using these methods it is not user friendly to be able to filter results by these taxonomy terms as i can't find an effective way of filtering through large taxonomies using Toolset. A text search can be too vague (no prompts for user etc), there are too many terms active for the other methods to work (cannot list 1000 terms), yet there is nothing in between these at all? In my opinion what is the point in being able to categorise by something that is not easily filtered through. It kind of goes against the point of categorising right?

The other option, as has been suggested, is that I could use countries and cities as custom post types and then link them via a relationship. Although the dropdowns still wouldn't be searchable, I would be able to split countries and cities into different drop downs like in the example with the real estate training site. This would make the filtering a lot easier for users on the front end.

I would just like to know, before I potentially migrate to this system, are there any limitations to doing it this way? I.E. Is there going to be anything that I won't be able to do with the custom post types and relationships that I would of been able to do if I had left it as a taxonomy.

I hope this makes a bit more sense now at least!

#1210878

Is there going to be anything that I won't be able to do with the custom post types and relationships that I would of been able to do if I had left it as a taxonomy.
I understand what you're asking, but I do not know how it would be possible for me to answer this realistically or effectively. The two things have many different features and are used in different ways throughout the entire software suite. They are implemented in completely different ways from a technical perspective. Create a View of some taxonomy, then look at the filter options. These are completely different from Custom Post Type and post relationship filters. There are shortcodes specific for taxonomies and taxonomy Views that don't exist for Custom post type Views and vice versa. Taxonomy queries are executed in the database completely differently. I could go on and on, and never tell you every difference between them or predict whether you would consider those limitations. If there is a specific question you have, I'll do my best to answer it. This one is just too broad for me to process here.

#1211998

Ben

Thank you for the reply Christian.

I understand that I am asking a very broad question here, where there is no "one size fits all" answer, so I apologise for that.

I will try and do as much testing as I possible can before deciding on a final solution for this. And If I have any further questions I will ask them as and when I do.

It's just frustrating to have to spend so much time on this because of (in my opinion!) such a long oversight in terms of fundamental display features and options regarding the taxonomies.

#1212649

I was thinking about this over the weekend and one important difference I'd like to point out is that while you can add many taxonomy filters in a single View, it is not currently possible to add more than one post relationship filters. You can add filters for multiple generations of one-to-many post relationships, but you cannot add filters for different lines of post relationship. For example, if you made a generational post relationship filter for country > state > city, then you could not also add a generational post relationship filter for class > order > family > genus > species, or any other line of post relationship. On the other hand, you can add multiple front-end filters for these classifications as taxonomies but they would not be split hierarchically into multiple fields.

I think this is a very important difference to understand upfront when dealing with custom search Views.

#1213221

Ben

Thank you for pointing this out Christian.

Ironically this was the first thing I encountered when testing the move, however In my situation I don't believe that I can effectively filter via a large amount of taxonomy terms, so I will have to settle for this compromise.

Do you know if the ability to add multiple post relationship filters is on the roadmap?