get_the_author()获取当前文章的作者名称

目录

描述

Retrieve the post author. This tag must be used within The Loop.

To display a page for authors which have no posts, see this discussion.

Since WordPress 2.1 parameters are deprecated (not the function).

get_the_author() 描述

用法

 <?php $author get_the_author(); ?> 

get_the_author() 用法

参数

$deprecated

(string) (可选) Deprecated.

默认值: ''

get_the_author() 参数

示例

Grab the Author's 'Public' Name

Grabs the value in the user's Display name publicly as field.

/* ----------------------------------
 * wordpress之魂 © http://wphun.com
 * ---------------------------------- */
<?php $author = get_the_author(); ?>

get_the_author() 示例

历史

添加于 版本: 1.5.0

get_the_author() 历史

源文件

get_the_author() 函数的代码位于 wp-includes/author-template.php.

/* ----------------------------------
 * wordpress之魂 © http://wphun.com
 * ---------------------------------- */
/**
 * Retrieve the author of the current post.
 *
 * @since 1.5.0
 *
 * @global object $authordata The current author's DB object.
 *
 * @param string $deprecated Deprecated.
 * @return string|null The author's display name.
 */
function get_the_author($deprecated = '') {
	global $authordata;

	if ( !empty( $deprecated ) )
		_deprecated_argument( __FUNCTION__, '2.1' );

	/**
	 * Filter the display name of the current post's author.
	 *
	 * @since 2.9.0
	 *
	 * @param string $authordata->display_name The author's display name.
	 */
	return apply_filters('the_author', is_object($authordata) ? $authordata->display_name : null);
}

get_the_author() 源文件

相关