Last active
August 29, 2015 14:27
-
-
Save will83/694c388a4612ca9c6d56 to your computer and use it in GitHub Desktop.
Object depth function
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
function get_object_depth( $object_id, $object_type ){ | |
$ancestors = get_ancestors( $object_id, $object_type ); | |
return count($ancestors); | |
// 0 => level 1 (first parent) | |
// 1 => level 2 | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
$object_id
(int or string) (required) The ID of the child object
Default: None
$object_type
(string) (required) The name of the object type (page, hierarchical post type, category, or hierarchical taxonomy) in question
Default: None