the_author

函式
the_author ( $deprecated = '', $deprecated_echo = true )
引數
  • (string) $deprecated Deprecated.
    Required:
    Default: (empty)
  • (bool) $deprecated_echo Deprecated. Use get_the_author(). Echo the string or return it.
    Required:
    Default: true
返回值
  • (string|null) The author's display name, from get_the_author().
相關
  • get_the_author()
定義位置
相關方法
the_author_idthe_author_msnthe_author_aimthe_author_icqthe_author_yim
引入
0.71
棄用
-

the_author: 該函式顯示當前文章的作者或指定使用者的顯示名稱。

顯示當前文章的作者姓名。

這個函式的行為是基於get_the_author()之前的舊功能: 這個函式並沒有被廢除,但它被設計為呼應get_the_author()的值,作為一個結果,任何可能仍然使用舊的行為的舊主題也會傳遞get_the_author()的值。

這個函式的正常的、預期的行為是呼應作者而不返回。然而,必須保持向後相容。

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();
}

常見問題

FAQs
檢視更多 >