comment_type() WordPress Function

The comment_type() function is used to get the type of comment currently being processed.

comment_type( string|false $commenttxt = false, string|false $trackbacktxt = false, string|false $pingbacktxt = false ) #

Displays the comment type of the current comment.


Parameters

$commenttxt

(string|false)(Optional) String to display for comment type.

Default value: false

$trackbacktxt

(string|false)(Optional) String to display for trackback type.

Default value: false

$pingbacktxt

(string|false)(Optional) String to display for pingback type.

Default value: false


Top ↑

Source

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


Top ↑

Changelog

Changelog
VersionDescription
0.71Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More