页面载入中..

凤凰不归巢

不懂的时间久了,就明白了;不会的多练了,就会了;看着别人会的,因为自己不会,所以才觉得他们厉害.
首页 » 编程技术 » 非插件为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. DkillJer 说:

    牛XX啊! , 正直兄教教我吧 , 这么牛的你要干什么啊 , 我都害怕你危害社会! , 嘻嘻 :lks:

  2. 集趣 说:

    有时间,咱也弄个!!

  3. 看到代码就头疼 我一点技术都不懂 哈哈

  4. 好东西,收藏,过几天也加上拉风下 :cool:

  5. 叶子 说:

    读者墙变身成友情链接了

  6. 皓辰 说:

    我喜欢……

  7. 学习了,博主分享的好啊 :cx:

  8. :jy: 我想请问下你们这个鼠标经过链接移动的是不是插件呢?真的很棒,个人很喜欢。请问有的分享吗??

  9. knife 说:

    为何我一加functions.php下的代码,整个控制台上方就变成了代码呢?

  10. :dx: :dx: 谢谢分享,支持一下。

有事没事评论一下!?

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 



品味人生

酸、甜、苦、辣

媒体相关

网上好玩意

搞笑玩意

生活要有乐趣

杂七杂八

什么乱七八糟的

编程技术

我的专业我的梦

资源共享

好东西要分享