Title: comment_excerpt
Published: April 25, 2014
Last modified: April 28, 2025

---

# comment_excerpt( int|WP_Comment $comment_id )

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/comment_excerpt/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/functions/comment_excerpt/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/functions/comment_excerpt/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/functions/comment_excerpt/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/comment_excerpt/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/functions/comment_excerpt/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/functions/comment_excerpt/?output_format=md#wp--skip-link--target)

Displays the excerpt of the current comment.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/comment_excerpt/?output_format=md#parameters)󠁿

 `$comment_id`int|[WP_Comment](https://developer.wordpress.org/reference/classes/wp_comment/)
optional

[WP_Comment](https://developer.wordpress.org/reference/classes/wp_comment/) or ID
of the comment for which to print the excerpt.
 Default current comment.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/comment_excerpt/?output_format=md#source)󠁿

    ```php
    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 );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/comment-template.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/comment-template.php#L703)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/comment-template.php#L703-L718)

## 󠀁[Hooks](https://developer.wordpress.org/reference/functions/comment_excerpt/?output_format=md#hooks)󠁿

 [apply_filters( ‘comment_excerpt’, string $comment_excerpt, string $comment_id )](https://developer.wordpress.org/reference/hooks/comment_excerpt/)

Filters the comment excerpt for display.

## 󠀁[Related](https://developer.wordpress.org/reference/functions/comment_excerpt/?output_format=md#related)󠁿

| Uses | Description | 
| [get_comment_excerpt()](https://developer.wordpress.org/reference/functions/get_comment_excerpt/)`wp-includes/comment-template.php` |

Retrieves the excerpt of the given comment.

  | 
| [apply_filters()](https://developer.wordpress.org/reference/functions/apply_filters/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to a filter hook.

  | 
| [get_comment()](https://developer.wordpress.org/reference/functions/get_comment/)`wp-includes/comment.php` |

Retrieves comment data given a comment ID or comment object.

  |

[Show 1 more](https://developer.wordpress.org/reference/functions/comment_excerpt/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/comment_excerpt/?output_format=md#)

| Used by | Description | 
| [_wp_dashboard_recent_comments_row()](https://developer.wordpress.org/reference/functions/_wp_dashboard_recent_comments_row/)`wp-admin/includes/dashboard.php` |

Outputs a row for the Recent Comments widget.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/comment_excerpt/?output_format=md#changelog)󠁿

| Version | Description | 
| [4.4.0](https://developer.wordpress.org/reference/since/4.4.0/) | Added the ability for `$comment_id` to also accept a [WP_Comment](https://developer.wordpress.org/reference/classes/wp_comment/) object. | 
| [1.2.0](https://developer.wordpress.org/reference/since/1.2.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/functions/comment_excerpt/?output_format=md#user-contributed-notes)󠁿

 1.  [Skip to note 2 content](https://developer.wordpress.org/reference/functions/comment_excerpt/?output_format=md#comment-content-1425)
 2.   [Codex](https://profiles.wordpress.org/codex/)  [  10 years ago  ](https://developer.wordpress.org/reference/functions/comment_excerpt/#comment-1425)
 3. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fcomment_excerpt%2F%23comment-1425)
    Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fcomment_excerpt%2F%23comment-1425)
 4. **Example**
 5.     ```php
        <p>Latest comment: <?php comment_excerpt(); ?></p>
        ```
    
 6.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fcomment_excerpt%2F%3Freplytocom%3D1425%23feedback-editor-1425)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fcomment_excerpt%2F)
before being able to contribute a note or feedback.