This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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