get_comment_type

Advertisement

Summery Summery

Retrieves the comment type of the current comment.

Syntax Syntax

get_comment_type( int|WP_Comment $comment_ID )

Parameters Parameters

$comment_ID

(Optional) WP_Comment or ID of the comment for which to get the type. Default current comment.

Return Return

(string) The comment type.

Source Source

File: wp-includes/comment-template.php

 *
 * @param int|WP_Comment $comment_ID Optional. WP_Comment or ID of the comment for which to get the type.
 *                                   Default current comment.
 * @return string The comment type.
 */
function get_comment_type( $comment_ID = 0 ) {
	$comment = get_comment( $comment_ID );

	if ( '' === $comment->comment_type ) {
		$comment->comment_type = 'comment';
	}

	/**
	 * Filters the returned comment type.
	 *
	 * @since 1.5.0
	 * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added.
	 *

Advertisement

Changelog Changelog

Changelog
Version Description
4.4.0 Added the ability for $comment_ID to also accept a WP_Comment object.
1.5.0 Introduced.

Advertisement

Leave a Reply