如果你的博客人气还算不错,那么一定要加上读者墙,展现你的读者;如果你的博客还没有多少人气,也要加上读者墙,鼓励读者多多访问——总之,读者墙是一个好东西!
如果你使用的是 Wordpress ,那么请继续看下去,否则就不要看啦!先让你们瞧瞧效果,诱惑你们加上读者墙——效果在侧边栏……啊,别打我了,我懒得放图片了啦!咳咳,要为自己的博客加上读者墙,请先在适当加入以下代码——
<?php
$identity="comment_author";
$passwordpost = " AND post_password=''";
$userexclude = " AND user_id='1' and comment_author != '梦帝'";
$approved = " AND comment_approved='1'";
$shownumber = 20;
$counts = $wpdb->get_results("SELECT COUNT(" . $identity . ") 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 MONTH(comment_date)=MONTH(now()) and YEAR(comment_date)=YEAR(now())" .
$userexclude . $passwordpost . $approved . ") AS tempcmt GROUP BY " . $identity . " ORDER BY cnt DESC LIMIT " . $shownumber);
echo '<ul class="duzhewall">';
if ( $counts ) : foreach ($counts as $count) :
echo '<li>' . '<a href="'. $count->comment_author_url . '" target="_blank” title=”' . $count->comment_author . ' ('. $count->cnt . '层楼)"><img src="http://www.gravatar.com/avatar.php?gravatar_id='.md5($count->comment_author_email).'&size=32&d=identicon&r=G" alt="' . $count->comment_author . ' ('. $count->cnt . '层楼)" /></a></li>';
endforeach; endif;
echo '</ul>';
?>
“适当位置”是什么位置总不要我说了吧,你想放在侧边栏就放在侧边栏,想放在单独页面就放在单独页面,然后稍加修改即可!
附:$userexclude 变量中的“闪闪的星”表示要屏蔽显示的人的名称(一般为管理员),$shownumber 变量则是表示显示数量咯!