[wp-trac] [WordPress Trac] #44279: `get_terms()` with `child_of` and `childless` combined

WordPress Trac noreply at wordpress.org
Wed May 30 15:30:32 UTC 2018


#44279: `get_terms()` with `child_of` and `childless` combined
--------------------------+-----------------------------
 Reporter:  nonverbla     |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Taxonomy      |    Version:  4.9.6
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 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:
 {{{#!php
 <?php
 $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.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/44279>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list