WordPress酷炫读者墙

酷炫读者墙【具体效果可以见:http://www.andy87.net/test-2
利用以下源代码创建一个新的页面模板,这样还可以显示你想添加的其他内容!OK,上代码:
PHP代码:

				<!-- start 读者墙  Edited By iSayme-->
<?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 comment_date > date_sub( NOW(), INTERVAL 24 MONTH ) AND user_id='0' AND comment_author_email != '568841659@qq.com' AND post_password='' AND comment_approved='1' AND comment_type='') AS tempcmt GROUP BY comment_author_email ORDER BY cnt DESC LIMIT 39";//大家把管理员的邮箱改成你的,目的是从读者墙里面排除博客作者,最后的数字39是读者的个数,可以按照自己的情况修改!
$wall = $wpdb->get_results($query);
$maxNum = $wall[0]->cnt;
foreach ($wall as $comment)
 {
 $width = round(40 / ($maxNum / $comment->cnt),2);//此处是对应的血条的宽度
 if( $comment->comment_author_url )
 $url = $comment->comment_author_url;
 else $url="#";
 $avatar = get_avatar( $comment->comment_author_email, $size = '36', $default=   get_bloginfo('wpurl').'/avatar/default.jpg' );
 $tmp = "<li><a target=\"_blank\" href=\"".$comment->comment_author_url."\">".$avatar."<em>".$comment->comment_author."</em> <strong>+".$comment->cnt."</strong></br>".$comment->comment_author_url."</a></li>";
 $output .= $tmp;
}
 $output = "<ul class=\"readers-list\">".$output."</ul>";
 echo $output ;
?>
<!-- end 读者墙 -->


如果觉的麻烦可以直接下载:点我下载,上传至当前主题目录下即可,建立页面时选择改模板就OK
CSS代码:

.readers-list{line-height:18px;text-align:left;overflow:hidden;_zoom:1}
.readers-list li{width:200px;float:left;*margin-right:-1px}
.readers-list a,.readers-list a:hover strong{background-color:#f2f2f2;background-image:-webkit-linear-gradient(#f8f8f8,#f2f2f2);background-image:-moz-linear-gradient(#f8f8f8,#f2f2f2);background-image:linear-gradient(#f8f8f8,#f2f2f2)}
.readers-list a{position:relative;display:block;height:36px;margin:4px;padding:4px 4px 4px 44px;color:#999;overflow:hidden;border:#ccc 1px solid;border-radius:2px;box-shadow:#eee 0 0 2px}
.readers-list img,.readers-list em,.readers-list strong{-webkit-transition:all .2s ease-out;-moz-transition:all .2s ease-out;transition:all .2s ease-out}
.readers-list img{width:36px;height:36px;float:left;margin:0 8px 0 -40px;border-radius:2px}
.readers-list em{color:#666;font-style:normal;margin-right:10px}
.readers-list strong{color:#ddd;width:40px;text-align:right;position:absolute;right:6px;top:4px;font:bold 14px/16px microsoft yahei}
.readers-list a:hover{border-color:#bbb;box-shadow:#ccc 0 0 2px;background-color:#fff;background-image:none}
.readers-list a:hover img{opacity:.6;margin-left:0}
.readers-list a:hover em{color:#EE8B17;font:bold 12px/36px microsoft yahei}
.readers-list a:hover strong{color:#EE8B17;right:150px;top:0;text-align:center;border-right:#ccc 1px solid;height:44px;line-height:40px}

将以上css代码添加到style.css中
具体截图看下面:

注明:本文参照 【Ifonder、WordPress – Feel So Good !】http://ifonder.com/2012/05/03/wordpress-reader-wall/ ,仅供参考

评论 ( 12)
  1. 沙发
    烂番茄 2014-06-01 04:14

    哈哈,不错的哈~ :good:

  2. 板凳
    韦德亚洲 2013-06-26 06:28

    我找了好久这个。就想要这种效果。终于找到了。。很帅啊。。。

    • 回复
      andy 2013-06-27 00:29
      @韦德亚洲 @韦德亚洲 : 这个和我演示页面的还是有一点区别的
  3. 地板
    ★Extreme★ 2012-10-04 10:03

    Good,还能显示名字,我自己做的只能显示头像,收藏了!

  4. 4 楼
    飛天鼠 2012-10-04 01:56

    读者墙人多的话加载很慢 ❓

  5. 5 楼
    乐猪 2012-09-28 15:13

    技术男啊。这个要果断的收藏一下,以后绝对能用得到

  6. 6 楼
    www.datacentersky.com 2012-09-27 01:13

    原来也搞了一个,但是怕代码太多影响整体性能就下了。

  7. 7 楼
    洋纸钞 2012-09-22 13:42

    哈哈,图片上面也有我 :mrgreen:

  8. 8 楼
    大发 2012-09-22 11:48

    图片上居然有两个我,哇哈哈。

  9. 9 楼
    锻铜雕塑 2012-09-22 07:27

    技术贴 学习了

  10. 10 楼
    过往云烟 2012-09-21 09:47

    效果可以,但是懒的折腾了.