get_the_author_ID()
云策文档标注
概述
get_the_author_ID() 是一个已弃用的 WordPress 函数,用于获取当前文章作者的 ID。自 2.8.0 版本起,建议使用 get_the_author_meta('ID') 替代。
关键要点
- 函数功能:返回当前文章作者的 ID,类型为字符串或整数。
- 弃用状态:自 WordPress 2.8.0 版本起被弃用,使用 _deprecated_function() 标记。
- 替代方案:推荐使用 get_the_author_meta('ID') 来获取作者 ID。
- 历史版本:在 1.5.0 版本中引入,2.8.0 版本弃用。
代码示例
function get_the_author_ID() {
_deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta('ID')' );
return get_the_author_meta('ID');
}注意事项
开发者应避免在新代码中使用此函数,转而使用 get_the_author_meta('ID') 以确保兼容性和最佳实践。
原文内容
Retrieve the ID of the author of the current post.
Description
See also
Source
function get_the_author_ID() {
_deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta('ID')' );
return get_the_author_meta('ID');
}
Changelog
| Version | Description |
|---|---|
| 2.8.0 | Deprecated. Use get_the_author_meta() |
| 1.5.0 | Introduced. |