Skip to content

Instantly share code, notes, and snippets.

@saqibsarwar
Last active April 11, 2016 17:21
Show Gist options
  • Save saqibsarwar/9c1d663c53b79ce0f11eae8d2db2fd5b to your computer and use it in GitHub Desktop.
Save saqibsarwar/9c1d663c53b79ce0f11eae8d2db2fd5b to your computer and use it in GitHub Desktop.
<?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