WordPress at a glance

comment_type() WP 1.0

Display the comment type of the current comment.

Works based on: get_comment_type()

No Hooks.

Return

Nothing (null).

Usage

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

Code of comment_type: wp-includes/comment-template.php VER 4.9.8

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

Related Functions

From category: Comments

No comments
    Hello, !     Log In . Register