国内外主机
测评及优惠码

WordPress炫酷css3读者墙代码分享


前话

WordPress炫酷css3读者墙,在本站就可以看到绚丽的读者墙的效果,介于本wordpress主题是购买的,所以就在网上找了篇一样的教程分享给大家。演示地址:http://www.wpmee.com/guestbook/ 好像掩耳盗铃的赶脚,啊哈哈。
先看个wordpress读者墙效果图吧:

实现教程

①、制作读者墙页面

首先复制你主题的page.php页面,改名为readerwall.php,然后在顶部 添加如下代码

<?php /* Template Name: Reader wall */ ?>  

继续搜索<?php the_content(”);?>,在这句代码前面添加下面的代码:

<?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 != '改成你的邮箱账号' 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 ; ?>  

②、添加超酷CSS3代码美化读者墙页面,在你主题的style.css里添加如下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:rightright;position:absolute;rightright: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;rightright:150px;top:0;text-align:center;border-right:#ccc 1px solid;height:44px;line-height:40px}   

OVER,本次wordpress教程结束,快去试一试吧。文章来源:http://www.html5cn.org/forum.php?mod=viewthread&tid=1079

赞一个
赞(0)
版权声明:本文采用知识共享 署名4.0国际许可协议 [BY-NC-SA] 进行授权
文章名称:《WordPress炫酷css3读者墙代码分享》
文章链接:https://www.ibytx.com/1262.html
本站资源仅供个人学习交流,请于下载后24小时内删除,不允许用于商业用途,否则法律问题自行承担。