In several places I use the system of 2 levels of views for location terms retrieving.
For example, to get all countries, which are children of several continents, I use 2 views:
- parent view - retrieve all continents' taxonomy terms (terms with no parent)
- sub view - retrieve all children of term passed from parent view
Or another example: to retrieve all big cities in the USA (big cities are usually children of states, when small cities - are under big cities), I use 2 views:
- parent view - retrieve all states taxonomy terms (terms with parent "USA")
- sub view - retrieve all children of term passed from parent view
In some cases I need to display the tree structure in template, so that 2 levels of loops is ok.
But in some cases I need to display just the list of terms, which I receive from sub view. Like list of all countries - not separated by continent. Or List of all big cities of US - not separated by state. It's possible to do in 1 SQL request, just by transferring the parent id. But via Toolset Views GUI it's obviously impossible.
Is it possible to pass the list of parent terms to the sub view and get all groups of children in one SQL request?
I can't quite tell from your description exactly what the set up of your taxonomies are, but if you have a taxonomy with just a 2-level hierarchy ( e.g. continents < countries) and you want a View to simply return all countries, you could set a query filter where filter you need is that the term is childless. (Continents have child terms, countries do not.)
You can't do that directly in the GUI (it only allows you to set a condition such as the parent is none), but—rather than looking at directly constructing SQL queries—you can use the API filters to modify the taxonomy query generated by the View.
Nigel, you got my request correctly, except of I have multileveled taxonomy - Continents->Countries->States->Big Cities->Villages.
And for one case I need to get all Countries but with 1 resulting request. For another case - Big Cities. I can't defer them by present/absent of parent.
But the continents and states - is the permanent list, so I'd want to make a request of all terms, whose parents are in list of IDs (list of all continents, for example, or list of all states).
To my eyes, it looks like the only relevant arguments you can set are child_of, parent, or childless.
You can use parent = 0 to retrieve the top level terms.
You can use childless = true to retrieve the bottom level terms.
For everything in between it seems clear that you must use more than a single query, likely starting at the top and iterating down with a new query for each level in the hierarchy.
The way WordPress stores the data I can't see an alternative.