Example 1 — Basic use
Print the text in a comment callback.
<div class="comment-content">
<?php comment_text(); ?>
</div> How It Works
- WordPress prints the saved message.
- The text is wrapped in a
ptag. - Your wrapper
divis used for styling.

In WordPress, comment_text() prints the body of a comment, which is the message the visitor wrote.
It prints the text after WordPress filters have run. By default this turns blank lines into paragraphs and makes links clickable.
Call it inside the comment loop, or pass a comment ID.
comment_text();
comment_text( 15 ); | Call | What it does |
|---|---|
comment_text() | Prints the text of the current comment. |
comment_text( 15 ) | Prints the text of comment 15. |
get_comment_text() | Returns the raw text without filters. |
The output is wrapped in paragraph tags, for example <p>Great post!</p>.
comment_text( int|WP_Comment $comment_id = 0, array $args = array() ): void | Parameter | Description |
|---|---|
$comment_id | Optional. A comment ID or WP_Comment object. Default is the current comment. |
$args | Optional. An array of arguments passed to the comment_text filter. |
| Return Value | Description |
|---|---|
| void | Nothing is returned. The function prints the comment text. |
Three short theme examples. Each one has a sample output.
Print the text in a comment callback.
<div class="comment-content">
<?php comment_text(); ?>
</div> p tag.div is used for styling.Show a notice when the comment is not approved yet.
<?php if ( '0' === $comment->comment_approved ) : ?>
<p><em>Your comment is awaiting moderation.</em></p>
<?php endif; ?>
<?php comment_text(); ?> $comment is passed to your callback.0 means the comment is waiting for approval.Use get_comment_text() when you need a short plain text.
<?php $text = get_comment_text(); ?>
<p><?php echo esc_html( wp_trim_words( $text, 10 ) ); ?></p> get_comment_text() returns the raw text.wp_trim_words() keeps the first 10 words.esc_html() makes the result safe.Print the comment text in a form that is safe for an RSS feed.
9 people found this page helpful