wordpress笔记之读者墙+留言板

在wordpress中是不自带留言板功能的,之前一直是复制了一page.php然后自定义的留言板,后来发现了页面读者墙这个好玩的功能,索性就把读者墙和留言板这两个功能给放在了一起,效果还不错的说。

先加上这段

<?php
/*
Template Name: commentswall
*/
?>

在就是这段

<!-- start 读者墙 -->
                            <?php
                                $query="SELECT COUNT(comment_ID) AS cnt, comment_author, comment_author_url, comment_author_email FROM (SELECT * FROM $wpdb->comments LEFT OUTER JOIN $wpdb->posts ON ($wpdb->posts.ID=$wpdb->comments.comment_post_ID) WHERE user_id='0' AND comment_author_email != 'sailor9066@gmail.com' AND post_password='' AND comment_approved='1' AND comment_type='') AS tempcmt GROUP BY comment_author_email ORDER BY cnt DESC LIMIT 41";
                                $wall = $wpdb->get_results($query);
                                foreach ($wall as $comment)
                                {
                                    if( $comment->comment_author_url )
                                    $url = $comment->comment_author_url;
                                    else $url="#";
                                    $tmp = "<a href='".$url."' title='".$comment->comment_author." (".$comment->cnt."条评论)' target='_blank' rel='external nofollow'>".get_avatar($comment->comment_author_email, 40)."</a>";
                                    $output .= $tmp;
                                 }
                                echo $output ;
                            ?>
                            <!-- end 读者墙 -->

然后就是跟留言板集成了~这个就不用唠叨什么了吧~

当然同样的方法还有标签云页面:

wp_tag_cloud()

用到这个函数而已~

折腾笔记系列


作者  :  sailor

仅仅看明白了还不够,能把别人给讲明白了才算及格。


  1. DH
    1#
    DH

    留言板不错。

    September 27th, 2011 at 04:36 pm
      1. sailor
        sailor

        嘿嘿,谢谢夸奖~~~~[face:daxiao][face:daxiao]

        October 20th, 2011 at 03:02 am
  2. 我竟然只是留言板的第二名,岂有此理?我非得将harry_L挤下来。
    [face:daxiao]

    September 27th, 2011 at 04:50 pm
      1. 你扯淡厉害!

        September 29th, 2011 at 07:39 pm
          1. sailor
            sailor

            看来群众的眼睛是雪亮的

            October 20th, 2011 at 03:03 am
      2. sailor
        sailor

        哈哈,很久没有写博客了,看来我要努力去你那里抢个第一

        October 20th, 2011 at 03:03 am
          1. 本来你的评论数是46,亨sir48,不过你今天评论两次,并驾齐驱了,哈哈!!
            [face:touxiao]

            October 20th, 2011 at 10:14 am
              1. sailor
                sailor

                额,看来他们都不怎么给力啊,我这么长时间不上还有这成绩,哈哈[face:daxiao][face:daxiao][face:daxiao]

                October 21st, 2011 at 01:23 pm
                  1. 我定的规矩严了点:互动中的主动算评论,被动算回复。如果按通用标准,你应该过70了。
                    [face:guilian]

                    October 21st, 2011 at 04:41 pm
  3. 不错,等我需要的时候再来折腾

    October 18th, 2011 at 07:07 pm
      1. sailor
        sailor

        呵呵,谢谢关注,欢迎再来

        October 20th, 2011 at 03:04 am
  4. 伊林
    4#
    伊林

    你这家伙也不写详细点,像我这样的菜鸟看了也要研究半天

    December 11th, 2011 at 10:32 pm
      1. YQC
        YQC

        额,实在抱歉。。。[face:haixiu]

        December 1st, 2012 at 01:17 pm
  5. 夜灵
    5#
    夜灵

    发觉和你使用着一样的主题中,想弄读者墙,当按你分享的代码总是出现错误,博主是不是还有什么还没分享出来的呢?例如样式?

    June 2nd, 2012 at 03:28 pm

评论已关闭


最新文章