标题其实有些夸张,实际上是对于本博留言板的读者墙重点介绍.
看着别人博客都有个读者墙,眼红,就也弄了个,有想过也塞侧边栏,不过冲着留言板有些空缺,再是参考万戈的留言板里边是文章订阅的,不过我暂时不想整那玩意,于是将读者墙放留言板了.
至于它为什么叫活友情链接,因为它每个月归每个月的,代码自己判断了,所以称之为活恰到好处.
上张图给大伙过过瘾.
先声明我是从万戈博客《WordPress 免插件读者墙修订版》偷过来的.但我研究了一小部分时间后,有些改进,当然了,我还是使用WP固有的get_avatar函数,原生嘛,实际是考虑到它风格的问题.
万戈的代码我就不发了,直接贴上我自己正在用的,因为有些小改动.
主题目录下functions.php部分
/* 读者墙 */
$identity="comment_author";
$passwordpost = " AND post_password=''";
$userexclude = " AND user_id='0' and comment_author != '成'";
$approved = " AND comment_approved='1'";
$shownumber = 42;
$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);
$identity="comment_author";
$passwordpost = " AND post_password=''";
$userexclude = " AND user_id='0' and comment_author != '成'";
$approved = " AND comment_approved='1'";
$shownumber = 42;
$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);
留言板部分(记得要加div):
<h3>本月【<?php echo date('Y年m月');?>】评论/留言排行榜</h3>
<ul class="ffox_most_active">
<?php if ( $counts ) :
foreach ($counts as $count) :
$mc+=1;
echo '<li>' . '<a href="'. $count->comment_author_url . '" target="_blank" title="第' .$mc.'名是: '. $count->comment_author . ' ('. $count->cnt . '条评论/留言)">'.get_avatar($count->comment_author_email,32,'','第'.$mc.'名是: '.$count->comment_author . ' ('. $count->cnt . '条评论/留言)').'</a></li>';
endforeach; endif;
?>
</ul>
<ul class="ffox_most_active">
<?php if ( $counts ) :
foreach ($counts as $count) :
$mc+=1;
echo '<li>' . '<a href="'. $count->comment_author_url . '" target="_blank" title="第' .$mc.'名是: '. $count->comment_author . ' ('. $count->cnt . '条评论/留言)">'.get_avatar($count->comment_author_email,32,'','第'.$mc.'名是: '.$count->comment_author . ' ('. $count->cnt . '条评论/留言)').'</a></li>';
endforeach; endif;
?>
</ul>
style.css部分:
/* 读者墙 */
.ffox_most_active li {
list-style:none;
float:left;
border:none;
padding-left:0;
width:41px;
background:none;
}
.ffox_most_active img {
width:32px;
height:32px;
}
.ffox_most_active li {
list-style:none;
float:left;
border:none;
padding-left:0;
width:41px;
background:none;
}
.ffox_most_active img {
width:32px;
height:32px;
}
- 转载请注明来源:凤凰不归巢 » 《非插件为WP打造活友情链接》
- 本文链接地址:http://wancheng.li/1355.html

本文有 69 条评论
呵呵。不错啊。可惜我的是ZB的
趁早跟上大伙步伐,换
还真的是换了。
我立马瞧瞧去
很强!不过还是算了,这些天忙书市的活动,没这功夫弄了 :ku: 改天吧
赶紧
过来支持一下~~用外面的ip
你真有心,精神可嘉,不管了,我去你博客耍去
:dx: 刚一进来还以为是万戈的站,呵呵。 , , 首页flash在Google浏览器下有几个无法显示。
有个问题就是,盖楼需要插件吗?就是那个可以回复的盖楼方式。
可回复的盖楼方式?啥意思?是不是嵌套评论? , 另外,害怕弄错代码可以本地装个WP,先本地测试,通过再搞服务器上
是啊,就是嵌套,怎么弄的呢? :ka:
这个是主题自带,其原理我也没研究过呢.
这个插件貌似我有
:han: 害怕弄代码,一弄就出错。
黑色显眼啊,能更好的将字体颜色突出
貌似大家都用WP,我奥特了 :han:
赶紧换上啊.呵呵
:toux: 不错嘛..呵呵.. , 一进来..还以为是万戈的博客呢..风格太想… , 我见到代码就头晕,喜欢插件,哈哈..
回赠ip :toux: