Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
<?php
if ( ! function_exists( 'inspiry_get_term_depth' ) ) :
/**
* Returns an integer value that tells the term depth in it's hierarchy
*
* @param $term_id
* @param $term_taxonomy
* @return int
*/
function inspiry_get_term_depth( $term_id, $term_taxonomy ) {
$term_ancestors = get_ancestors( $term_id, $term_taxonomy );
if ( $term_ancestors ) {
return count( $term_ancestors );
}
return 0;
}
endif;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment