comment_type()WP 0.71

Displays the name of the comment type. The names can be arbitrary.

Comments in WordPress are divided into types: regular comment, Trackback, or Pingback.

If you do not need to display data, use the function get_comment_type().

No Hooks.

Returns

null.

Usage

<?php comment_type($comment, $trackback, $pingback); ?>
$comment(string)
The name that will be displayed on the screen if it is a regular comment.
Default: 'Comment'
$trackback(string)
The name that will be displayed on the screen if it is a trackback.
Default: 'Trackback'
$pingback(string)
The name that will be displayed on the screen if it is a ping.
Default: 'pingback'

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.9

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