站长资源
中国站长网站

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()

本文出处:来自互联网信息共享,请勿相信收费信息站长资源 » WordPress模板包含标签:comments_template()详解

评论 抢沙发

评论前必须登录!