[wp-trac] [WordPress Trac] #59503: Multiple Parent Term Id parameter in get_terms

WordPress Trac noreply at wordpress.org
Fri Sep 29 14:49:59 UTC 2023


#59503: Multiple Parent Term Id parameter in get_terms
-------------------------+-----------------------------
 Reporter:  plugindevs   |      Owner:  < plugindevs>
     Type:  enhancement  |     Status:  assigned
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  Taxonomy     |    Version:
 Severity:  normal       |   Keywords:  has-patch
  Focuses:               |
-------------------------+-----------------------------
 Currently, there is no option to get child terms of multiple parent terms.
 There is a
 '**parent**' parameter that returns child terms of only one parent term.

 There is a '**post parent in**' parameter for '**WP_Query**' and
 '**get_posts()**' to get child posts of multiple parent posts, but there
 is no similar parameter for '**WP_Term_Query**', and '**get_terms()**'.

 So, I suggest a new parameter '**parents in**' to get child terms from
 multiple parent terms IDs. The parameter on get_terms() will be like
 below:
 {{{#!php
 <?php
     /**
      *
      *  @type int[] $parents__in
      *  Array of comma-separated parent terms ID to retrieve child terms
 of given array.
      *  Default empty array.
      *
      */
     get_terms( array(
         'taxonomy'    => 'category',
         'parents__in' => array( 2, 3, 4 )
     ) );
 }}}

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


More information about the wp-trac mailing list