_get_post_ancestors()
云策文档标注
概述
_get_post_ancestors() 是一个已弃用的 WordPress 函数,用于检索文章的祖先,自 WordPress 3.5.0 起不再推荐使用,因为 WP_Post 类已通过 get_post_ancestors() 懒加载 ancestors 属性。
关键要点
- 函数 _get_post_ancestors() 已弃用,建议使用 get_post_ancestors() 替代。
- 该函数接受一个 WP_Post 对象参数,但实际未使用。
- 弃用信息通过 _deprecated_function() 标记,并在使用时通知开发者。
注意事项
在开发中应避免使用此函数,转而使用 get_post_ancestors() 以确保代码兼容性和最佳实践。
原文内容
Retrieve post ancestors.
Description
This is no longer needed as WP_Post lazy-loads the ancestors property with get_post_ancestors() .
See also
Parameters
$postWP_Postrequired-
Post object, passed by reference (unused).
Source
function _get_post_ancestors( &$post ) {
_deprecated_function( __FUNCTION__, '3.5.0' );
}
Changelog
| Version | Description |
|---|---|
| 3.5.0 | Deprecated. Use get_post_ancestors() |
| 2.3.4 | Introduced. |