Get child categories of custom taxonomy category?

Use get_terms() to get the child terms of a given term. You need to feed the specific term id to either

  • parent 

(integer) Get direct children of this term (only terms whose explicit parent is this value). If 0 is passed, only top-level terms are returned. Default is an empty string.

OR

  • child_of

– (integer) Get all descendents of this term. Default is 0. Note: the difference between child_of and parent is that where parentonly gets direct children of the parent term (ie: 1 level down), child_of gets all descendants (as many levels as are available)

EXAMPLE:

Get all descendants of term ID 80

(Requires PHP 5.4+)

$terms = get_terms( 'portfolio_category', ['child_of' => 80] );

For only first level children, change child_of to parent

tech