评论模版文件的命名为:comments.php
这里需要掌握的方法:
– comments_template();
作用:调用评论模版。
– comments_open();
作用:判断是否开启文章评论的功能,返回ture表示开启,false表示关闭。简单的判断评论是否关闭。
<?php
if(!comments_open()){
echo '<li class="tip-box"><p><a href="">评论已经关闭</a></p></li>';
}
?>
post_password_required();
作用:判断当前文章是否需要输入密码并且正确输入。如果正确就返回false,如果错误就返回true。
<?php
if(!comments_open()){
echo '<li class="tip-box"><p><a href="">评论已经关闭</a></p></li>';
}else if(post_password_required()){
echo '<li class="tip-box"<p>请输入密码在查看评论内容!</p></li>';
}
?>
have_comments();
作用:判断是否有评论。如果没有评论返回true反正返回false。wp_list_comments();
作用:输出当前文章的所有评论。is_user_logged_in();
作用:判断用户是否登陆。comment_form();
作用:输出评论的窗口。