Function Reference/comments template
Português do Brasil •
(Add your language)
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
<?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' ); ?>
- 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.
comments_template() is located in
Available Filters and Actions
List of comment filters and actions