A bit of a similar question to the one I had before about nested loops, but instead of listing only the child terms of the current parent category being accessed, I want to list all child terms.
It’s easy enough to use the All Terms option when using a Looper Provider but that will list all parents and child terms. The brute force method would be to exclude the parent terms in the Taxonomy option but this becomes a bit of an ugly solution if you have 10, 20 parent terms involved.
I’ve been thinking through some solutions and it basically boils down to:
- Use Looper Provider (All Terms) and exclude parent terms
- Make a menu widget with only children terms
- Custom filter code
I’m going to try to build something custom based off the help I’ve received in the past as that seems like the best option but if I could, I would love to suggest a future feature for using the All Terms Looper Provider option where excluding all parent terms would be possible.
Trying to think my way through the 3rd option here but I know that if I were to use custom code, i can do the reverse and get all the top level terms at least:
$parent_terms = get_terms([
'taxonomy' => 'partner',
'hide_empty' => 'true,',
'parent' => 0
]);
// Handle potential errors
if (is_wp_error($parent_terms)) {
return [];
}
return $parent_terms;
Only question is figuring out where to go from here to extract just the children terms.