外贸独立站的底层设计密码WordPress 成品站模板
当前位置:首页>WordPress建站>WordPress开发>WordPress函数:comments_template(获取评论模板)

WordPress函数:comments_template(获取评论模板)

描述

加载评论模板。只能用于单篇 文章 或 页面 来显示评论,如果不是这些页面,将没办法显示。

用法

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

参数

$file
(字符串string) (可选) 要加载的文件

默认: /comments.php
$separate_comments
(布尔值boolean) (可选) 是否根据评论的类型划分评论

默认: false

例子

默认用法

<?php comments_template(); ?> 

另类的评论模板

在某些情况下,你希望以不同的方式来显示你的评论,那么,你可以建立一个自定义的文件(例如 short-comments.php),并且通过下面的方式调用:

<?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() 包含在 wp-includes/comment-template.php.

可用过滤器和动作

List of comment filters and actions

相关函数

comment_form()

get_header(), get_footer(), get_sidebar(), get_template_part(), get_search_form()

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

给TA打赏
共{{data.count}}人
人已打赏
欢迎关注WordPress大学公众号 WPDAXUE
WordPress开发

WordPress函数:get_search_form(获取搜索表单)

2013-4-5 7:35:00

WordPress开发

WordPress函数:bloginfo(显示博客信息)

2013-4-5 7:59:00

5 条回复 A文章作者 M管理员
  1. 这评论是自带的吗?就是改了样式?我都不知道comments.php要写点什么鬼

  2. zhoushaofeijjz

    请问如何才能前台显示评论,然后能够删除评论的

  3. 测试代码样式
    (function() {
    "use strict";

    function inject(str)
    {
    var elem = document.createElement("script");

    elem.setAttribute("type", "application/javascript");
    elem.textContent = "(function() {\"use strict\"; (" + str + ")();})();";

    document.body.appendChild(elem);
    }

  4. 小白表示只看懂了一点点。

    • 测试,两个字不能发送?

个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索