get_the_author_posts_link

函式
get_the_author_posts_link ( No parameters )
返回值
  • (string) An HTML link to the author page, or an empty string if $authordata isn't defined.
定義位置
相關方法
the_author_posts_linkget_the_author_postsget_the_author_linkget_author_rss_linkget_author_posts_url
引入
4.4.0
棄用
-

get_the_author_posts_link: 這個函式檢索到文章作者的檔案頁的連結,連結文字是作者的名字和已發表文章的數量。它不接受任何引數,並返回一個HTML格式的連結。

檢索一個指向當前文章作者頁面的HTML連結。

使用get_author_posts_url()返回一個HTML格式的連結。

function get_the_author_posts_link() {
	global $authordata;
	if ( ! is_object( $authordata ) ) {
		return '';
	}

	$link = sprintf(
		'<a href="%1$s" title="%2$s" rel="author">%3$s</a>',
		esc_url( get_author_posts_url( $authordata->ID, $authordata->user_nicename ) ),
		/* translators: %s: Author's display name. */
		esc_attr( sprintf( __( 'Posts by %s' ), get_the_author() ) ),
		get_the_author()
	);

	/**
	 * Filters the link to the author page of the author of the current post.
	 *
	 * @since 2.9.0
	 *
	 * @param string $link HTML link.
	 */
	return apply_filters( 'the_author_posts_link', $link );
}

常見問題

FAQs
檢視更多 >