函数文档

get_the_author_firstname()

💡 云策文档标注

概述

get_the_author_firstname() 是一个已弃用的 WordPress 函数,用于获取当前文章作者的名字。自 2.8.0 版本起,建议使用 get_the_author_meta('first_name') 替代。

关键要点

  • 函数功能:返回当前文章作者的名字(字符串类型)。
  • 弃用状态:自 WordPress 2.8.0 版本起被弃用,应改用 get_the_author_meta('first_name')。
  • 相关函数:get_the_author_meta() 用于获取作者元数据,_deprecated_function() 用于标记弃用函数。

代码示例

function get_the_author_firstname() {
	_deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta('first_name')' );
	return get_the_author_meta('first_name');
}

注意事项

  • 在开发新代码时,避免使用此弃用函数,以保持兼容性和最佳实践。
  • 如果维护旧代码,建议逐步替换为 get_the_author_meta('first_name')。

📄 原文内容

Retrieve the first name of the author of the current post.

Description

See also

Return

string The author’s first name.

Source

function get_the_author_firstname() {
	_deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta('first_name')' );
	return get_the_author_meta('first_name');
}

Changelog

Version Description
2.8.0 Deprecated. Use get_the_author_meta()
1.5.0 Introduced.