How to get immediate children of a ‘term’ parent id through ‘get_terms’?


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
  • 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.

sariDon 2 years 2020-12-21T08:10:43-05:00 0 Answers 6 views 0

Leave an answer