设为首页 - 加入收藏 ASP站长网(Aspzz.Cn)- 我们致力于打造专业的站长资讯、交流、合作平台!
热搜: 站长之家 基础 优化
当前位置: 主页 > 运营中心 > 建站资源 > 优化 > 正文

WordPress优化:查询百度收录、自动同步微博带图片等(5)

发布时间:2015-01-28 12:58 所属栏目:[优化] 来源:站长网
导读:三、WordPress酷炫CSS3读者墙:按年、月、日排名 1、WordPress酷炫CSS3读者墙这个玩意一般不用我多说,大部分用WordPress的博主都了解过了,为了增强评论的积极性,我们可以热心读者按月份排行,甚至还可以一周为单

三、WordPress酷炫CSS3读者墙:按年、月、日排名

1、WordPress酷炫CSS3读者墙这个玩意一般不用我多说,大部分用WordPress的博主都了解过了,为了增强评论的积极性,我们可以热心读者按月份排行,甚至还可以一周为单位,进一步激励读者评论留言。

WordPress酷炫CSS3读者墙:按年、月、日排名

2、实现以上效果,可以直接使用以下代码(同时存在多个时间段):

  • <!-- 张戈博客修改版读者墙排行代码 -->
  • <style type="text/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}
  • </style>
  • <h2>年度评论排行 TOP3</h2>
  • <?php  
  • $query1="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 between date_sub(now(),interval 1 year) and now() 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 3";  
  • $wall = $wpdb->get_results($query1);   
  • $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 = '32', $default = get_bloginfo('wpurl').'/avatar/default.jpg' );   
  • $tmp = "<li><a rel=\"friend\" alt=\"avatar头像\" target=\"_blank\" href=\"".$comment->comment_author_url."\">".$avatar."<em>".$comment->comment_author."</em> <strong>+".$comment->cnt."</strong></br>".$comment->comment_author_url."</a></li>";  
  • $output1 .= $tmp;  
  • }   
  • $output1 = "<ul class=\"readers-list\">".$output1."</ul>";   
  • echo $output1 ;  
  • ?>   
  • <!-- end 年度排行 --> 
  • <div class="clear"></div>           
  • <br />
  • <h2>本月评论排行 TOP6</h2>
  • <?php  
  • $query2="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 date_format(comment_date,'%Y-%m')=date_format(now(),'%Y-%m') 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 6";  
  • $wall = $wpdb->get_results($query2);   
  • $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 = '32', $default = get_bloginfo('wpurl').'/avatar/default.jpg' );   
  • $tmp = "<li><a rel=\"friend\" alt=\"avatar头像\" target=\"_blank\" href=\"".$comment->comment_author_url."\">".$avatar."<em>".$comment->comment_author."</em> <strong>+".$comment->cnt."</strong></br>".$comment->comment_author_url."</a></li>";  
  • $output2 .= $tmp;  
  • }   
  • $output2 = "<ul class=\"readers-list\">".$output2."</ul>";   
  • echo $output2 ;  
  • ?>   
  • <!-- end 本月排行 -->
  • <div class="clear"></div>           
  • <br />
  • <h2>本周评论排行 TOP9</h2>
  • <?php  
  • $query3="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 yearweek(date_format(comment_date,'%Y-%m-%d')) = yearweek(now()) 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 9";  
  • $wall = $wpdb->get_results($query3);   
  • $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 = '32', $default = get_bloginfo('wpurl').'/avatar/default.jpg' );   
  • $tmp = "<li><a rel=\"friend\" alt=\"avatar头像\" target=\"_blank\" href=\"".$comment->comment_author_url."\">".$avatar."<em>".$comment->comment_author."</em> <strong>+".$comment->cnt."</strong></br>".$comment->comment_author_url."</a></li>";  
  • $output3 .= $tmp;  
  • }   
  • $output3 = "<ul class=\"readers-list\">".$output3."</ul>";   
  • echo $output3 ;  
  • ?>   
  • <!-- end 本周排行·全部结束 -->

(编辑:ASP站长网)

网友评论
推荐文章