comment_type

函式
comment_type ( $commenttxt = false, $trackbacktxt = false, $pingbacktxt = false )
引數
  • (string|false) $commenttxt Optional. String to display for comment type. Default false.
    Required:
    Default: false
  • (string|false) $trackbacktxt Optional. String to display for trackback type. Default false.
    Required:
    Default: false
  • (string|false) $pingbacktxt Optional. String to display for pingback type. Default false.
    Required:
    Default: false
定義位置
相關方法
get_comment_typecomment_textcomment_datecomment_timecomments_open
引入
0.71
棄用
-

comment_type: 此函式返回當前評論的型別,如”評論”、”回貼”或”回軌”。

顯示當前評論的評論型別。

function comment_type( $commenttxt = false, $trackbacktxt = false, $pingbacktxt = false ) {
	if ( false === $commenttxt ) {
		$commenttxt = _x( 'Comment', 'noun' );
	}
	if ( false === $trackbacktxt ) {
		$trackbacktxt = __( 'Trackback' );
	}
	if ( false === $pingbacktxt ) {
		$pingbacktxt = __( 'Pingback' );
	}
	$type = get_comment_type();
	switch ( $type ) {
		case 'trackback':
			echo $trackbacktxt;
			break;
		case 'pingback':
			echo $pingbacktxt;
			break;
		default:
			echo $commenttxt;
	}
}

常見問題

FAQs
檢視更多 >