Displays the comment type of the current comment.
$commenttxtstring|falseoptional
Default:false
$trackbacktxtstring|falseoptional
Default:false
$pingbacktxtstring|falseoptional
Default:false
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. |
© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/comment_type