public static function get_page_depth($page = null)
    {
        if ($page === null) {
            global $wp_query;

            $object = $wp_query->get_queried_object();
        } else {
            $object = \get_post($page);
        }

        $parent_id  = $object->post_parent;
        $depth = 0;

        while ($parent_id > 0) {
            $page = \get_post($parent_id);
            $parent_id = $page->post_parent;
            $depth++;
        }

        return $depth;
    }
public static function get_page_depth($page = null)
    {
        if ($page === null) {
            global $wp_query;

            $object = $wp_query->get_queried_object();
        } else {
            $object = \get_post($page);
        }

        $parent_id  = $object->post_parent;
        $depth = 0;

        while ($parent_id > 0) {
            $page = \get_post($parent_id);
            $parent_id = $page->post_parent;
            $depth++;
        }

        return $depth;
    }
public static function get_page_depth ( $ page = null ) { if ( $ page === null ) { global $ wp_query ; $ object = $ wp_query -> get_queried_object ( ) ; } else { $ object = \ get_post ( $ page ) ; } $ parent_id = $ object -> post_parent ; $ depth = 0 ; while ( $ parent_id > 0 ) { $ page = \ get_post ( $ parent_id ) ; $ parent_id = $ page -> post_parent ; $ depth ++ ; } return $ depth ; }
Get current page depth.

@since  1.0.0

@param int|\WP_Post|null $page Optional. Post ID or post object. Defaults to the current queried object.
@return integer
Get current page depth .