常用函数-comments_template()

1条评论

说明

该函数加载评论模板,并显示在单篇文章和页面中。

用法

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

参数

$file

(字符串)(可选)将要加载的文件

默认值:/comments.php

$separate_comments

(布尔型)(可选)是否按评论类型分隔评论

默认值:false

示例

使用其它评论模板

有时你可能希望在主题的不同部分显示不同评论效果。那么你需要新建一个替换文件(如short-comments.php)并按以下方式调用该文件:

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

注释

  • 使用全局变量:(数组)当前文章评论对象的$comment列表
  • 用法:$wpdb
  • 用法:$id
  • 用法:$post
  • 用法:若文章没有评论,$withcomments将不会尝试获取评论

历史记录

  • 始见于1.5.0版本

源文件

comments_template()位于wp-includes/general-template.php中。

相关资源

get_header, get_sidebar, get_search_form, comments_template, get_footer()

 

#1
这个函数里面如何控制css?评论模版的css怎样调整

发表新评论

此内容将保密,不会被其他人看见。
  • 自动将网址与电子邮件地址转变为链接。
  • 允许HTML标签:<a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • 自动断行和分段。

更多关於格式化选项的信息

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.