Make WordPress Core

Opened 3 weeks ago

#44279 new defect (bug)

`get_terms()` with `child_of` and `childless` combined

Reported by: nonverbla Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.9.6
Component: Taxonomy Keywords:
Focuses: Cc:


Hi there! I'm not sure if I found a bug or this is intended behaviour: If I use a combination of childless and child_of in a get_terms call, I get zero results. My taxonomy's structure:

- Genre
-- Hip Hop
-- Trap
-- Rap
- Location
-- Europe
--- Germany
--- Sweden
--- Austria
-- Asia
--- China
--- Japan
--- Taiwan

My code:

$location_parent = get_term(123, 'my_custom_taxonomy');

$countries = get_terms(array(
  'taxonomy' => $location_parent->taxonomy,
  'hide_empty' => false,
  'child_of' => $location_parent->term_id, 
  'childless' => true

I'm trying to only list countries, basically children of 'location' that don't have children of their own.

Change History (0)

Note: See TracTickets for help on using tickets.