Determine if Term has Grandparent/Great-Grandparent
Use get_ancestors() and count the returned array: that’s the number of ancestors a term has. /** * Count a term’s ancestors. * * @param int $term_id * @param string $taxonomy * @return int */ function wpse_57512_count_ancestors( $term_id = FALSE, $taxonomy = FALSE ) { if ( FALSE === $term_id and ! empty ( get_queried_object()->taxonomy ) … Read more