页面载入中..

凤凰不归巢

不懂的时间久了,就明白了;不会的多练了,就会了;看着别人会的,因为自己不会,所以才觉得他们厉害.
首页 » 编程技术 » 非插件为WP打造活友情链接

非插件为WP打造活友情链接

bcjs category

标题其实有些夸张,实际上是对于本博留言板的读者墙重点介绍.
看着别人博客都有个读者墙,眼红,就也弄了个,有想过也塞侧边栏,不过冲着留言板有些空缺,再是参考万戈的留言板里边是文章订阅的,不过我暂时不想整那玩意,于是将读者墙放留言板了.
至于它为什么叫活友情链接,因为它每个月归每个月的,代码自己判断了,所以称之为活恰到好处.
上张图给大伙过过瘾.
huoyoulian

先声明我是从万戈博客《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);

留言板部分(记得要加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>

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;
}

本文有 69 条评论

  1. 呵呵。不错啊。可惜我的是ZB的

  2. 很强!不过还是算了,这些天忙书市的活动,没这功夫弄了 :ku: 改天吧

  3. 过来支持一下~~用外面的ip

  4. 说:

    :dx: 刚一进来还以为是万戈的站,呵呵。 , , 首页flash在Google浏览器下有几个无法显示。

  5. 说:

    有个问题就是,盖楼需要插件吗?就是那个可以回复的盖楼方式。

  6. 说:

    :han: 害怕弄代码,一弄就出错。

  7. kaka 说:

    :cool: 来支持支持~~ , 你的代码背景色 能换个不。黑色看着累

  8. C.C 说:

    貌似大家都用WP,我奥特了 :han:

  9. zzy90 说:

    :toux: 不错嘛..呵呵.. , 一进来..还以为是万戈的博客呢..风格太想… , 我见到代码就头晕,喜欢插件,哈哈..

  10. 冰古 说:

    回赠ip :toux:

有事没事评论一下!?

icon_wink.gif icon_neutral.gif icon_mad.gif icon_twisted.gif icon_smile.gif icon_eek.gif icon_sad.gif icon_rolleyes.gif icon_razz.gif icon_redface.gif icon_surprised.gif icon_mrgreen.gif icon_lol.gif icon_idea.gif icon_biggrin.gif icon_evil.gif icon_cry.gif icon_cool.gif icon_arrow.gif icon_confused.gif icon_question.gif icon_exclaim.gif 



品味人生

酸、甜、苦、辣

媒体相关

网上好玩意

搞笑玩意

生活要有乐趣

杂七杂八

什么乱七八糟的

编程技术

我的专业我的梦

资源共享

好东西要分享