WordPress函数文档comments_template()

导入comments.php文件 描述 Loads the comment template. For use…

导入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”.

用法

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

参数

$file

(string) (可选) The file to load

默认值: /comments.php

$separate_comments

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

默认值: false

示例

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:

注意

  • 使用到 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() 函数的代码位于 wp-includes/comment-template.php.

相关

  • Filter(过滤器): comments_template
  • Function(函数): comment_form()

Include Tags

  • Function(函数): get_header(),
  • Function(函数): get_footer(),
  • Function(函数): get_sidebar(),
  • Function(函数): get_template_part(),
  • Function(函数): get_search_form(),
  • Function(函数): comments_template()
  • 原文:http://codex.wordpress.org/Function_Reference/comments_template
类别:WordPress函数文档

本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。

评论 (0)COMMENT