wpseek.com
WordPress开发者和主题制作者的搜索引擎



the_author › WordPress Function

Since0.71
已弃用n/a
the_author ( $deprecated = '', $deprecated_echo = true )
参数: (2)
  • (string) $deprecated Deprecated.
    Required: No
    默认: (empty)
  • (bool) $deprecated_echo Deprecated. Use get_the_author(). Echo the string or return it.
    Required: No
    默认: true
链接:
查看:
返回:
  • (string) The author's display name, from get_the_author().
定义在:
文档:

Displays the name of the author of the current post.

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.


源码

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',
			sprintf(
				/* translators: %s: get_the_author() */
				__( '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();
}