wordpress侧边栏读者墙实现方法[转]

wordpress侧边栏读者墙实现方法[转]

作者:李俊杰 时间:2012-06-08 分类:wordpress相关 评论:2 条 浏览:1136
我在网上看到侧边栏读者墙的实现方法 今天和大家分享一下!
把代码放到sidebar.php 中
具体代码:

  1. <!– 读者墙 –>
  2. <div>
  3. <h2>吐槽大神</h2>
  4. <ul>
  5. <?php
  6. $counts = $wpdb->get_results(“SELECT COUNT(comment_author) 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 1 MONTH ) AND user_id=’0′ AND comment_author != ‘疯孩子’ AND post_password=” AND comment_approved=’1′ AND comment_type=”) AS tempcmt GROUP BY comment_author ORDER BY cnt DESC LIMIT 18″);
  7. foreach ($counts as $count) {
  8. $c_url = $count->comment_author_url;
  9. if ($c_url == ”) $c_url = ‘http://www.fenghaizi.com/’;
  10. $mostactive .= ‘<li>’ . ‘<a href=”‘. $c_url . ‘” title=”‘ . $count->comment_author . ‘ (‘. $count->cnt . ‘次吐槽)”>’ . get_avatar($count->comment_author_email, 40) . ‘</a></li>’;
  11. }
  12. echo $mostactive;
  13. ?>
  14. </ul>
  15. </div>
  16. <!– 读者墙结束 –>

复制代码

DESC LIMIT 18 (把18换成你想要显示的数量)
comment_author != ‘疯孩子’ (把疯孩子替换成你的用户名)
$c_url = ‘http://www.fenghaizi.com/’; (换成你的网址)




参考CSS样式

  1. #sidebar .ffox_most_active{overflow:hidden;}
  2. #sidebar ul.ffox_most_active li{padding-left:0;}
  3. #sidebar .ffox_most_active li{list-style:none;float:left;line-height:0;border:none;background:none;}
  4. #sidebar .ffox_most_active img.avatar{width:36px;height:36px;border:1px solid #ddd;padding:2px;margin:0 1px 0 0;}


标签:

相关推荐
更多

  1. 男士包包 2012-6-10 16:15 #1 回复TA

    对于我新人,看得有点困难

发表评论

电子邮件地址不会被公开。 必填项已用*标注