comment_excerpt()WP 1.2.0

Display the excerpt of the current comment.

1 time — 0.000975 sec (slow) | 50000 times — 5.40 sec (fast)
Hooks from the function

Return

null. Nothing (null).

Usage

comment_excerpt( $comment_id );
$comment_id(int|WP_Comment)
WP_Comment or ID of the comment for which to print the excerpt.
Default: current comment

Examples

0

#1 Demo

<p>Latest comment: <?php comment_excerpt(); ?></p>

Displays:

<p>Latest comment: Can you please teach me the correct way to use this plugin to count the number of clicks on external…</p>

Changelog

Since 1.2.0 Introduced.
Since 4.4.0 Added the ability for $comment_id to also accept a WP_Comment object.

comment_excerpt() code WP 6.5.3

function comment_excerpt( $comment_id = 0 ) {
	$comment = get_comment( $comment_id );

	$comment_excerpt = get_comment_excerpt( $comment );

	/**
	 * Filters the comment excerpt for display.
	 *
	 * @since 1.2.0
	 * @since 4.1.0 The `$comment_id` parameter was added.
	 *
	 * @param string $comment_excerpt The comment excerpt text.
	 * @param string $comment_id      The comment ID as a numeric string.
	 */
	echo apply_filters( 'comment_excerpt', $comment_excerpt, $comment->comment_ID );
}