返回介绍

the_author()

发布于 2017-09-11 10:31:31 字数 2776 浏览 1236 评论 0 收藏 0

the_author( string $deprecated = '',  string $deprecated_echo = true )

Display the name of the author of the current post.


description

The behavior of this function is based off of old functionality predating get_the_author(). This function is not deprecated, but is designed to echo the value from get_the_author() and as an result of any old theme that might still use the old behavior will also pass the value from get_the_author().

The normal, expected behavior of this function is to echo the author and not return it. However, backward compatibility has to be maintained.


参数

$deprecated

(string) (Optional) Deprecated.

Default value: ''

$deprecated_echo

(string) (Optional) Deprecated. Use get_the_author(). Echo the string or return it.

Default value: true


返回值

(string|null) The author's display name, from get_the_author().


源代码

File: wp-includes/author-template.php

function the_author( $deprecated = '', $deprecated_echo = true ) {
	if ( ! empty( $deprecated ) ) {
		_deprecated_argument( __FUNCTION__, '2.1.0' );
	}

	if ( true !== $deprecated_echo ) {
		_deprecated_argument( __FUNCTION__, '1.5.0',
			/* translators: %s: get_the_author() */
			sprintf( __( 'Use %s instead if you do not want the value echoed.' ),
				'<code>get_the_author()</code>'
			)
		);
	}

	if ( $deprecated_echo ) {
		echo get_the_author();
	}

	return get_the_author();
}

更新日志

Versiondescription
0.71Introduced.

相关函数

Uses

  • wp-includes/l10n.php: __()
  • wp-includes/functions.php: _deprecated_argument()
  • wp-includes/author-template.php: get_the_author()

User Contributed Notes

  1. Skip to note content You must log in to vote on the helpfulness of this noteVote results for this note: 0You must log in to vote on the helpfulness of this note Contributed by hearvox

    Display the post author’s name (in default name format, set in User profile’s “Display name publicly as” pulldown):

    <p>This post was written by <?php the_author(); ?></p>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文