Opened 3 years ago
Last modified 3 years ago
#59503 assigned enhancement
Multiple Parent Term Id parameter in get_terms
| Reported by: | plugindevs | Owned by: | < plugindevs> |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Taxonomy | Version: | |
| Severity: | normal | Keywords: | has-patch |
| Cc: | Focuses: |
Description
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 /** * * @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 ) ) );
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
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 onget_terms()will be like below:<?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 ) ) );Trac ticket: https://core.trac.wordpress.org/ticket/59503