WordPress函数:get_the_author 获取当前文章的作者

江河/ 2023年04月29日/ WordPress/ 浏览 1254

函数原型:


get_the_author( string $deprecated = '' ): string|null


获取当前文章的作者。


同函数 the_author 一样,参数 $deprecated 已不被推荐使用,这个参数就直接忽略好了。


函数源码:


function get_the_author( $deprecated = '' ) {
	global $authordata;

	if ( ! empty( $deprecated ) ) {
		_deprecated_argument( __FUNCTION__, '2.1.0' );
	}

	return apply_filters( 'the_author', is_object( $authordata ) ? $authordata->display_name : null );
}


包含钩子:


apply_filters( 'the_author', string|null $display_name )


使用举例:


$author = get_the_author();


发表评论

暂无评论,抢个沙发...

客服 工单