WordPress Comment Functions

About This Index
This page is the WordPress Comment Functions index. Each row links to a full guide with syntax, examples, and FAQs.
Learn how comments.php and the comment loop work on WordPress Comments. Use this page when you need one function, such as wp_list_comments(), comment_author(), or comment_form().
Start with wp_list_comments(), comment_author(), comment_text(), and comment_form(). Then learn comment_reply_link(), get_avatar(), and the page link functions.
How to Call a Comment Function
Most comment tags run for the current comment, so use them inside a wp_list_comments() callback. Counts and links such as comments_number() go in the post loop. Functions that start with get_ return a value.
<?php // comments.php ?>
<h2><?php comments_number(); ?></h2> <!-- count text -->
<ol class="comment-list">
<?php wp_list_comments( array( 'callback' => 'mytheme_comment' ) ); ?>
</ol>
<?php // in the callback ?>
<strong><?php comment_author(); ?></strong> <!-- prints the name -->
<?php comment_text(); ?> <!-- prints the message -->
<?php $img = get_avatar( $comment, 48 ); ?> <!-- returns the img tag -->
<?php comment_form(); ?> <!-- prints the form --> WordPress Comment Functions Table
All function guides in this WordPress comment series (30 tutorials).
Comment content & meta
8 functionsShow the message, date, time, ID, type, and CSS classes of a comment.
| Function | Description | Tutorial |
|---|---|---|
comment_text() | Print the text (body) of the current comment. | Read guide |
comment_excerpt() | Print a short plain-text excerpt of the current comment. | Read guide |
comment_date() | Print the date when the current comment was posted. | Read guide |
comment_time() | Print the time when the current comment was posted. | Read guide |
comment_ID() | Print the numeric ID of the current comment. | Read guide |
comment_type() | Print the type of the current comment: Comment, Trackback, or Pingback. | Read guide |
comment_class() | Print the class attribute with useful CSS classes for one comment. | Read guide |
comment_text_rss() | Print the comment text in a form that is safe for an RSS feed. | Read guide |
Frequently Asked Questions
Start with cancel_comment_reply_link()
Print the Cancel reply link, the first guide in the sidebar.
14 people found this page helpful
