Skip to content

add parents__in parameter for get_terms#5352

Open
Mobashir1995 wants to merge 1 commit intoWordPress:trunkfrom
Mobashir1995:get_terms-parents__in
Open

add parents__in parameter for get_terms#5352
Mobashir1995 wants to merge 1 commit intoWordPress:trunkfrom
Mobashir1995:get_terms-parents__in

Conversation

@Mobashir1995
Copy link

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 )
    ) );

Trac ticket: https://core.trac.wordpress.org/ticket/59503


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants