Home › Toolset Professional Support › [Resolved] How to add hierarchical taxonomy filters in a view
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 |
---|---|---|---|---|---|---|
- | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | - |
- | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | - |
Supporter timezone: Asia/Kolkata (GMT+05:30)
This topic contains 17 replies, has 3 voices.
Last updated by Minesh 1 year, 2 months ago.
Assisted by: Minesh.
Tell us what you are trying to do?
I have different taxonomies (country, provinces, regions, cities). Each country has several different provinces taxonomies, which also have several different regions taxonomies and so on to cities and districts. They all are individualised, as I understood parent-child taxonomies system was not the best way to achieve my goal.
In CRED, I am using conditional rules to hide and show taxonomies depending of the country / province / region selected, so only the good list of cities show up
I would like to do the same thing in the filter view, so my users can search for files, showing only the ones respecting all enabled filters.
I've tried [wpv-conditional if="( CONTAINS(#(pays),'Canada') )"], but it doesn't work. I'v tried with the taxonomy item ID, it doesn't work either.
Is there any documentation that you are following?
I've read many tickets, but I can't find my answer
Is there a similar example that we can see?
That's the page I'm working on : hidden link
And that the old (but stil used) filter page (which use only 2 taxonomies - City and Location categories). hidden link
What is the link to your site?
hidden link
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
Hi Catherine
If I understand you correctly, you have a country taxonomy, a province taxonomy, a region taxonomy, and a city taxonomy.
Toolset doesn't have a way to chain these together, such that if a user selects a country, then the provinces selector only offers provinces in that country, similarly with regions and cities as each is chosen.
In the Real Estate reference site we use post types rather than taxonomies for states and cities, connected to accommodation posts in a hierarchy of one-to-many post relationships. Then when you add hierarchical post relationship filters to a View you do get that sort of behaviour, namely, choose a State, then the Cities selector updates to show cities belonging to that state, etc.
There is a sense in which something like this can work with separate taxonomies.
Views search settings have a setting to only show filter values that would produce results, which dynamically updates filter options based on other filters that have already been set.
In this scenario, rather than the relationship between locations and sub-locations formally set up, they emerge organically from the data they are assigned to.
For example, if a user selects the country France then the results would update to only include results from France, but the taxonomy selector for provinces would also update and no longer show Ontario, for example, because there are no results tagged with both "France" country and "Ontario" province.
I think that approximates to what you describe.
Hi Nigel,
Yes, you've understood well.
The thing I'm note sure about, is that I don't have only 1 selector for provinces, I have 1 by country, then 1 by province, then each province has one for the regions and all the regions have one for the cities. So far I have 30 different taxonomies, and none are parent-child related.
France
- Regions
Canada
- Provinces
-- Quebec
---- Region 1
------ Cities
---- Region 2
------ CIties
---- Region 3... to 13 (with their cities)
-- Ontario
---- Region 1
---- Region 2 to ...
I've built it that way, because parent-child wasn't possible / was too heavy. Thought that would be easier.
Would it be simplier if I migrate to one-to-many post relationships? I'm not really used to work with this. Is this something we can easily add on the CRED form? (instead of clicking checkboxes for taxonomies, there would be checkboxes for post types)?
Finally, I've tried to find the dynamic option you told me about, but I can't find how to do it.
CAtherine 🙂
As Nigel shared there is no way to display dependent taxonomy.
Here is the Doc that you should follow that should help you to display dependent filters using views but you have to create post types for country, province ,region, city and then connect them with one to many post relationship.
Please try to follow the following Doc:
=> https://toolset.com/documentation/legacy-features/views-plugin/how-to-filter-by-related-posts/
Hi Minesh,
Thanks for the docs. But Nigel was speaking about a way to do it throught taxonomies. Is it possible to have the docs too?
As Nigel shared information:
Views search settings have a setting to only show filter values that would produce results, which dynamically updates filter options based on other filters that have already been set.
What if you edit your view and navigate to "Custom Search Settings" section and select option "Let me choose individual settings manually" and further select option "Show only available options for each input"
Does that helps? If no, then there is no way to build dependent filters using taxonomy.
Hi Minesh,
I can't find this option (and CTRL-F finds nothing)
Where do I go? I'm editing the view throught Toolset / Views, not in a page with Gutenberg
I've added two pictures of the only filters setting I can find, but nothing about what you said.
Catherine 🙂
Also, I've just tried to create a view with Gutenberg (blocks), but I don't have the option to create a new one, only to use an existing one. See picture.
Any thoughts?
And I have the latest version of the Toolset Plugins
I've solved the "unable to create a new view" part (https://toolset.com/forums/topic/create-new-view-not-appearing/)
Worked on the filter thing too. But it won't work.
Sélecting "show only options with results" make the filter narrow the options to the one that do have results, but it won't HIDE the filter itself. Si I'm still having the show/hide issue.
I would need conditionals to do so, but I can't make it work [wpv-conditional if="( CONTAINS(#(pays),'Canada') )"], but it doesn't work. I'v tried with the taxonomy item ID, it doesn't work either.
How does it work?
Can you please share problem URL and let me review that where you added the conditional statement and also share admin access details.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I have set the next reply to private which means only you and I have access to it.
Hi Minesh,
Sorry for late reply, I wanted to try few things before you enter the site and now, I have to rebuild the view before you can work on it.
I'll write back shortly
Thanks!
Ok fine - please get in touch with all required details when you can.
Hi Minesh,
While trying to fix something, I've disabled / enabled all plugins and now, I can't access the View tab. The system tells me that I don't have the rights to do so, even if I have the administrative level.
Could you have a look? The full backup is done.
Catherine
Here is the Doc that shows how you can enable the legacy views:
- https://toolset.com/course-lesson/enabling-legacy-version-of-toolset-views/#enabling-legacy-views