I have a hierarchical taxonomy filter
that contains locations and genres for posts with the custom type artist
:
- Genre
-- Hip Hop
-- Trap
-- Rap
- Location
-- Europe
--- Germany
--- Sweden
--- Austria
-- Asia
--- China
--- Japan
--- Taiwan
Now I would like to use get_terms() to only get the Countries (children of 'Location' without children of their own). I thought this should work:
$location_parent = get_term(123, 'filter');
$countries = get_terms(array(
'taxonomy' => $location_parent->taxonomy,
'hide_empty' => false,
'child_of' => $location_parent->term_id,
'childless' => true
));
...but it somehow doesn't. child_of
and childless
seem to get in each other's way. Any ideas?
genre
andlocation
taxonomy would be better, looking at your hierarchy though, could you just tell it not to recurse down and ignore children? Or use more than one request? This is probably one of those situations were the real problem is that you're asking too much of 1 function call and you're in need of multiple stepschildless
andchild_of
to work together, don't you think?filter
, notlocation
. I will edit my question so this becomes clearer.