admin管理员组

文章数量:1312858

I have a category orientation as:

Series (ID: 15) (root category)

Under 'Series', the following sub-categories are present:

  • Series A (Contains 0 posts)
  • Series B (Contains 1 post)
  • Series C (Contains 0 posts)

How can I get the all three subcategories under the 'Series' category using 'get_terms'?

I have used the following parameter structure sent as $args (term query) to 'get_terms' with no result. It returns an empty array:

$arg['taxonomy'] = 'category';
$arg['hide_empty'] = 0;
$arg['parent'] = 15;
$arg['number'] => 0;
$arg['orderby'] = 'term_id';
$arg['order'] = 'ASC';

What am i doing wrong?

Please note that I want to achieve this through 'get_terms' only so that I can use the same for other custom terms too.

I have a category orientation as:

Series (ID: 15) (root category)

Under 'Series', the following sub-categories are present:

  • Series A (Contains 0 posts)
  • Series B (Contains 1 post)
  • Series C (Contains 0 posts)

How can I get the all three subcategories under the 'Series' category using 'get_terms'?

I have used the following parameter structure sent as $args (term query) to 'get_terms' with no result. It returns an empty array:

$arg['taxonomy'] = 'category';
$arg['hide_empty'] = 0;
$arg['parent'] = 15;
$arg['number'] => 0;
$arg['orderby'] = 'term_id';
$arg['order'] = 'ASC';

What am i doing wrong?

Please note that I want to achieve this through 'get_terms' only so that I can use the same for other custom terms too.

Share Improve this question asked Dec 21, 2020 at 13:59 sariDonsariDon 2651 gold badge2 silver badges18 bronze badges 0
Add a comment  | 

1 Answer 1

Reset to default 0

You've set number to 0, so it will do as told and return 0 terms. Remove the number argument if you want all matching terms.

本文标签: categoriesHow to get immediate children of a 39term39 parent id through 39getterms39