函数文档

get_author_name()

💡 云策文档标注

概述

get_author_name() 函数用于获取指定作者的显示名称,但自 WordPress 2.8.0 起已被弃用,建议使用 get_the_author_meta('display_name') 替代。

关键要点

  • 函数 get_author_name() 已弃用,应改用 get_the_author_meta('display_name')
  • 参数 $auth_id 为可选整数,指定作者 ID,默认值为 false
  • 返回值为字符串类型的作者显示名称
  • 相关函数包括 get_the_author_meta() 和 _deprecated_function()

代码示例

function get_author_name( $auth_id = false ) {
    _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta('display_name')' );
    return get_the_author_meta('display_name', $auth_id);
}

注意事项

  • 此函数在 WordPress 2.8.0 版本中被标记为弃用,使用时会触发弃用通知
  • 建议更新代码以避免未来版本中可能出现的兼容性问题

📄 原文内容

Retrieve the specified author’s preferred display name.

Description

See also

Parameters

$auth_idintoptional
The ID of the author.

Default:false

Return

string The author’s display name.

Source

function get_author_name( $auth_id = false ) {
	_deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta('display_name')' );
	return get_the_author_meta('display_name', $auth_id);
}

Changelog

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