comment_type()WP 0.71

Display the comment type of the current comment.

No Hooks.

Return

null. Nothing (null).

Usage

comment_type( $commenttxt, $trackbacktxt, $pingbacktxt );
$commenttxt(string|false)
String to display for comment type.
Default: false
$trackbacktxt(string|false)
String to display for trackback type.
Default: false
$pingbacktxt(string|false)
String to display for pingback type.
Default: false

Examples

9

#1 A simple example of how use the function

<p><?php comment_type(); ?> to the posts: <?php the_title(); ?> </p>

Changelog

Since 0.71 Introduced.

comment_type() code WP 6.5.3

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