Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/comments template


Loads the comment template. For use in single Post and Page displays. Will not work outside of single displays unless $withcomments is set to "1".


<?php comments_template$file$separate_comments ); ?>


(string) (optional) The file to load
Default: /comments.php
(boolean) (optional) Whether to separate the comments by comment type.
Default: false


Default Usage

<?php comments_template(); ?> 

Alternative Comment Template

On some occasions you may want display your comments differently within your Theme. For this you would build an alternate file (ex. short-comments.php) and call it as follows:

<?php comments_template( '/short-comments.php' ); ?> 

The path to the file used for an alternative comments template should be relative to the current theme root directory, and include any subfolders. So if the custom comments template is in a folder inside the theme, it may look like this when called:

<?php comments_template( '/custom-templates/alternative-comments.php' ); ?> 


  • Uses global: (array) $comment List of comment objects for the current post
  • Uses: $wpdb
  • Uses: $id
  • Uses: $post
  • Uses: $withcomments Will not try to get the comments if the post has none.


Since: 1.5.0

Source File

comments_template() is located in wp-includes/comment-template.php.

Available Filters and Actions

List of comment filters and actions


Include Tags

See also index of Function Reference and index of Template Tags.