函数原型
comment_type( string|false $commenttxt = false, string|false $trackbacktxt = false, string|false $pingbacktxt = false )
函数描述
Displays the comment type of the current comment.
是否弃用
未弃用
函数参数
-
$commenttxt
string|false
Optional - String to display for comment type.
Default:
false -
$trackbacktxt
string|false
Optional - String to display for trackback type.
Default:
false -
$pingbacktxt
string|false
Optional - String to display for pingback type.
Default:
false
函数返回值
无
函数位置
File: wp-includes/comment-template.php.
函数源码
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;
}
}
源码链接
变更日志
| Version | Description |
|---|---|
| 0.71 | Introduced. |

