WordPress Comment Functions

Beginner
6 min read
Updated: Nov 2026
30 function guides
Function index

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().

Beginner path.

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.

WordPress
<?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 author & identity

9 functions

Show who wrote a comment: name, email, website, IP address, and avatar.

FunctionDescriptionTutorial
comment_author()Print the name of the person who wrote the current comment.Read guide
comment_author_link()Print the commenter's name as a link to their website.Read guide
comment_author_email()Print the email address of the current comment author.Read guide
comment_author_email_link()Print the commenter's email as a mailto link.Read guide
comment_author_url()Print the website address entered by the comment author.Read guide
comment_author_url_link()Print the commenter's website as a clickable link.Read guide
comment_author_IP()Print the IP address of the current comment author.Read guide
get_avatar()Return the HTML img tag of a user or commenter avatar.Read guide
comment_author_rss()Print the comment author's name for use in a comments RSS feed.Read guide

Comment content & meta

8 functions

Show the message, date, time, ID, type, and CSS classes of a comment.

FunctionDescriptionTutorial
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

Reply & form

5 functions

Build the comment form and the Reply and Cancel links.

FunctionDescriptionTutorial
comment_form()Print the complete comment form with fields and a submit button.Read guide
comment_form_title()Print the form heading, or a Reply to text when replying to a comment.Read guide
comment_reply_link()Print the Reply link that lets a visitor answer one comment.Read guide
cancel_comment_reply_link()Print the Cancel reply link shown while a visitor answers another comment.Read guide
comment_id_fields()Print the hidden input fields that connect a reply to its post and parent comment.Read guide

Counts, links & navigation

8 functions

Show counts, link to comments, list all comments, and split them into pages.

FunctionDescriptionTutorial
comments_number()Print the number of comments of a post as text.Read guide
comments_link()Print the URL of the comments section of the current post.Read guide
comments_popup_link()Print a link to the comments of a post, with the count as text.Read guide
wp_list_comments()Print the whole list of comments for a post, with nesting and avatars.Read guide
next_comments_link()Print the link to the next page of comments.Read guide
previous_comments_link()Print the link to the previous page of comments.Read guide
paginate_comments_links()Print numbered page links for a post with many comments.Read guide
permalink_comments_rss()Old template tag for the comments feed link. Use modern feed functions instead.Read guide

Frequently Asked Questions

They are template tags that print or return data about comments: the author, the text, the date, the form, the reply links, counts, and page links.
Most of them go in comments.php or in a wp_list_comments() callback. Count and link functions such as comments_number() go in the post loop.
comment_author() prints the name. get_comment_author() returns it so that you can use it in PHP.
Use wp_list_comments() to loop through the comments. Use single tags, such as comment_author() and comment_text(), inside its callback.
Call comment_form() at the end of comments.php. It prints the fields, the submit button, and the hidden fields.
Start with wp_list_comments(), comment_author(), comment_text(), and comment_form(). Then learn comment_reply_link() and the pagination functions.

Start with cancel_comment_reply_link()

Print the Cancel reply link, the first guide in the sidebar.

cancel_comment_reply_link() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

14 people found this page helpful