18、wordpress主题模版开发:评论模版的调用

评论模版文件的命名为: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();作用:输出评论的窗口。
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇