I have a directory of profiles here: hidden link
- Each profile has a taxonomy/category define which is the Province.
- Each profile has a city defined (e.g. Vancouver)
What I would like is when a province is selected, it would then auto-populate the second dropdown accordingly with the cities that are defined for that province only.
The problem I have now is that if I define a province, and a city, like British Columbia -> Vancouver, then I can't select any other province.
Here are how I have the options defined for the View: hidden link
I've set it to "Show only available options for each input", as if I "hide" them it won't even list the other Provinces in the scenario above. However if I set it to "Always show all values for inputs", then I would get "No results found" if I select Province and City combo that doesn't exist.
Is there a way to have the first dropdown set to "Always show all values for inputs" but have the second dropdown only display the corresponding cities?
Is there a way to have the first dropdown set to "Always show all values for inputs" but have the second dropdown only display the corresponding cities?
Hi, there's not an easy way to apply different criteria to the two dropdown filters like this. Instead, you have a few options to solve the problem of not being able to select a different Province after choosing "British Columbia" and "Vancouver":
1. In the Province select field, select "Select Province" instead of "British Columbia". This will reactivate all the Provinces and Cities for selection.
2. Add a "reset" button in your custom search and pagination editor for this View, which basically does just what I described above in one click. Now your Users have two methods to reset the first dropdown.
3. Consider adding a default selection in the Cities select field, like the "Select Province" option in the Province field. Without a City selected, the first dropdown should allow other selections. Also notice that the Barry city is selected by default, even though the Barry filter is not applied to the results until you submit the search form? A default option like "Select City" can help clear up that filter quirk.
Thanks for the recommendations, I will try them.
However, if I wanted the behavior as described what would be needed? Should I outsource this?
Basically the idea would be that the all Provinces are always visible and selectable, but the City dropdown only displays the corresponding cities for that province.
Exactly what you're describing would require custom code with JavaScript and PHP, and we don't provide support for customizing custom search filters like that here in the forums. We have a portal available for contacting independent contractors: https://toolset.com/contractors.
Check out the real estate reference site on discover-wp.com. It has a filter that behaves similarly to what you're describing, but the content is organized somewhat differently. Instead of using a taxonomy for Provinces, you would use a custom post type and a series of post relationships, where Cities are children of Provinces and Team Members are children of Cities.
You can see an example here: https://christiancox-22119-rel-1.discover-wp.com/
This custom search View uses States and Cities, similar to your Provinces and Cities. If you would like to see how this is set up, you can set up a free account at our sandbox site https://discover-wp.com. Then you can deploy the real estate reference site and check out the backend to see how this filter works.