Check if Current Category has Children

There may or may not be a better way to do this, but here’s how I would do it:

$term = get_queried_object();

$children = get_terms( $term->taxonomy, array(
'parent'    => $term->term_id,
'hide_empty' => false
) );
// print_r($children); // uncomment to examine for debugging
if($children) { // get_terms will return false if tax does not exist or term wasn't found.
    // term has children
}

If current taxonomy term has children the get_terms function will return an array, otherwise it will return false.

Tested and works on my local vanilla install with Custom Post Type UI plugin used for CPT generation.

Leave a Comment