comment_excerpt()
Displays a trimmed comment (maximum 20 words).
Uses: get_comment_excerpt()
1 time — 0.000975 sec (slow) | 50000 times — 5.40 sec (fast)
Hooks from the function
Returns
null.
Usage
<?php comment_excerpt( $comment_ID ); ?>
- $comment_ID(int/object)
- ID or object of the comment "quote" to retrieve.
Default: 0 - current comment
Examples
#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() comment excerpt code WP 6.9.1
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 );
}