dd

wordpress comments_template()调用评论模板函数


【函数介绍】

comments_template()用于在文章页面(post)或者独立页面(page)调用指定的评论模板文件的函数。

【函数使用】

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

【参数说明】

$file
(string) (可选) 需要载入的模板文件名(位于主题目录下)
默认: /comments.php
$separate_comments
(boolean) (可选) 是否以评论类型来显示评论.
默认: false

【函数实例】

1、调用主题下的评论模板文件comments.php:

<?php comments_template(); ?> 

2、不同的文章类型去显示文章评论

<?php comments_template(get_post_format().'-comment.php', true ); ?>

【源文件】

comments_template() 位于 wp-includes/comment-template.php.