comments_template()导入comments.php文件

目录

描述

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".

comments_template() 描述

用法

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

comments_template() 用法

参数

$file

(string) (可选) The file to load

默认值: /comments.php

$separate_comments

(boolean) (可选) Whether to separate the comments by comment type.

默认值: false

comments_template() 参数

示例

Default Usage

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:

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:

comments_template() 示例

注意

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

comments_template() 注意

源文件

comments_template() 函数的代码位于 wp-includes/comment-template.php.

comments_template() 源文件

相关