comments_template() – Loads the comment template specified in $file.

You appear to be a bot. Output may be restricted


Loads the comment template specified in $file.

Will not display the comments template if not on single post or page, or if the post does not have comments. Uses the WordPress database object to query for the comments. The comments are passed through the comments_array filter hook with the list of comments and the post ID respectively. The $file path is passed through a filter hook called comments_template , which includes the TEMPLATEPATH and $file combined. Tries the $filtered path first and if it fails it will require the default comment template from the default theme. If either does not exist, then the WordPress process will be halted. It is advised for that reason, that the default theme is not deleted. Will not try to get the comments if the post has none.


comments_template( $file, $separate_comments );


( string ) optional default: /comments.php – Optional. The file to load. Default '/comments.php'.
( bool ) optional – Optional. Whether to separate the comments by comment type. Default false.




File name: wordpress/wp-includes/comment-template.php

201 to 216 of 216
   * Filters the path to the theme template file used for the comments template.
   * @since 1.5.1
   * @param string $theme_template The path to the theme template file.
  $include = apply_filters( 'comments_template', $theme_template );

  if ( file_exists( $include ) ) {
    require $include;
  } elseif ( file_exists( TEMPLATEPATH . $file ) ) {
    require TEMPLATEPATH . $file;
  } else { // Backward compat code will be removed in a future release.
    require ABSPATH . WPINC . '/theme-compat/comments.php';

 View on GitHub View on Trac