get_the_author_lastname()
云策文档标注
概述
get_the_author_lastname() 是一个已弃用的 WordPress 函数,用于获取当前文章作者的姓氏。自 2.8.0 版本起,建议使用 get_the_author_meta('last_name') 替代。
关键要点
- 函数功能:返回当前文章作者的姓氏字符串。
- 弃用状态:自 WordPress 2.8.0 版本起被弃用,使用时会触发 _deprecated_function() 警告。
- 替代方案:推荐使用 get_the_author_meta('last_name') 来获取相同数据。
- 相关函数:get_the_author_meta() 用于获取作者元数据,_deprecated_function() 用于标记弃用函数。
代码示例
function get_the_author_lastname() {
_deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta('last_name')' );
return get_the_author_meta('last_name');
}注意事项
- 在开发新代码时,应避免使用此弃用函数,改用 get_the_author_meta('last_name') 以确保兼容性和最佳实践。
- 函数定义位于 wp-includes/author-template.php 文件中,相关变更记录在版本 1.5.0 引入,2.8.0 弃用。
原文内容
Retrieve the last name of the author of the current post.
Description
See also
Source
function get_the_author_lastname() {
_deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta('last_name')' );
return get_the_author_meta('last_name');
}
Changelog
| Version | Description |
|---|---|
| 2.8.0 | Deprecated. Use get_the_author_meta() |
| 1.5.0 | Introduced. |