【1】首先把你现在所用的主题的目录下的page.php这个文件复制一份到你的硬盘上。改名为Reader.php (其他名字也可以,但中文不可以)。

【2】用Notepad++、UltraEdit、EditPlus等文本编辑器打开Reader.php,在最前面加上:

31d20188c178cc78738aebe783c1a3d2000

【3】找到<?php the_content(); ?>,在他的前面加上:

<!-- start 读者墙 -->
<?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 1 YEAR) AND user_id=\'0\' AND comment_author_email != \'XXXX@163.com\' AND comment_author_email != \'XXXX@gmail.com\' AND post_password=\'\' AND comment_approved=\'1\' AND comment_type=\'\') AS tempcmt GROUP BY comment_author_email ORDER BY cnt DESC LIMIT 180";
$wall = $wpdb->get_results($query);
foreach ($wall as $comment)
{
if( $comment->comment_author_url )
$url = $comment->comment_author_url;
else $url="#";
$tmp = "<a rel=\'external nofollow\' href=\'".$url."\' target=\'_blank\' title=\'".$comment->comment_author." (".$comment->cnt.")\'>".get_avatar($comment->comment_author_email, 40)."</a>";
$output .= $tmp;
}
$output = "<div id=\'readerswall\'><h2>Readers Wall</h2>".$output."</div>";
echo $output ;
?>
<!-- end 读者墙 -->

里面几个数值,你可以根据自己需要修改:

[1 YEAR]   是统计的时间跨度。1 MONTH 是一个月,1 WEEK 是一周,1 SEASON是一季度。

[XXXX@163.com]   是排除掉博主自己的评论。

[180]   是显示多少个头像。

[40]    是头像尺寸。

修改完后,保存。

【4】把Reader.php上传到你现在用的主题的目录下。

【5】wordpress后台 → 页面 → 添加新页面。

标题随便起一个名字,可以是中文。建议起一个英文的别名,比如“ReadersWall”。

右边的“模版”,点开下拉菜单,选择“Wall” (就是刚刚上传的那个模版啦)。

发布页面。

【6】完成了。

从你的首页里找到这个新建的页面,点开看看吧。

写的够详细了,方便菜鸟学习。

祝大家愉快。

评论被关闭。