WordPress添加评论用户等级显示以及友情链接用户标注
![]() | ![]() | ![]() | ![]() |
| 【性价之王】 | 【线路之王】 | 【价格之王】 | 【配置之王】 |
| 【免费之王】 | 【香港首推】 | 【梯子之王】 | 【独服之王】 |

如果我们有经常转悠网友博客的时候是不是会看到评论留言处比较特别?经常看到用户等级的图片标注?这样的做法以来可以增加用户将互动,毕竟有些网友是很有虚荣心的,如果能显示自己的等级,会吸引更多的回访和提高等级。同时,如果网友有和这个博客友情链接,还会有特别的标注是邻居。
这样的效果是如何加上去的呢?
//评论用户等级提示
function get_author_class($comment_author_email,$comment_author_url){
global $wpdb;
$adminEmail = \\’管理员邮箱\\’;
$author_count = count($wpdb->get_results(
\\”SELECT comment_ID as author_count FROM $wpdb->comments WHERE comment_author_email = \\’$comment_author_email\\’ \\”));
if($comment_author_email ==$adminEmail)
echo \\\'<a class=\\”vip7\\” title=\\”评论超人就是你!\\”></a>\\’;
$linkurls = $wpdb->get_results(
\\”SELECT link_url FROM $wpdb->links WHERE link_url = \\’$comment_author_url\\’\\”);
if($author_count>=3 && $author_count<10 && $comment_author_email!=$adminEmail)
echo \\\'<a class=\\”vip1\\” title=\\”评论达人 LV.1\\”></a>\\’;
else if($author_count>=10 && $author_count<20 && $comment_author_email!=$adminEmail)
echo \\\'<a class=\\”vip2\\” title=\\”评论达人 LV.2\\”></a>\\’;
else if($author_count>=20 && $author_count<30 && $comment_author_email!=$adminEmail)
echo \\\'<a class=\\”vip3\\” title=\\”评论达人 LV.3\\”></a>\\’;
else if($author_count>=30 && $author_count<50 && $comment_author_email!=$adminEmail)
echo \\\'<a class=\\”vip4\\” title=\\”评论达人 LV.4\\”></a>\\’;
else if($author_count>=50 &&$author_count<80 && $comment_author_email!=$adminEmail)
echo \\\'<a class=\\”vip5\\” title=\\”评论达人 LV.5\\”></a>\\’;
else if($author_count>=80 && $author_coun<200 && $comment_author_email!=$adminEmail)
echo \\\'<a class=\\”vip6\\” title=\\”评论达人 LV.6\\”></a>\\’;
else if($author_count>=200 && $comment_author_email!=$adminEmail)
echo \\\'<a class=\\”vip7\\” title=\\”评论达人 LV.7\\”></a>\\’;
foreach ($linkurls as $linkurl) {
if ($linkurl->link_url == $comment_author_url )
echo \\\'<a class=\\”vp\\” target=\\”_blank\\” h=\\”/links/\\” title=\\”哟!隔壁邻居的呢!\\”></a>\\’;
}
}
这里将代码添加到当前主题Functions.php中。
同时,我们需要将下面代码添加到\\”<?php comment_author_link();?>\\”评论模板下面。
<?php get_author_class($comment->comment_author_email,$comment->comment_author_url,$comment->user_id)?>
如果需要加上博主认证的,需要加上:
<?php get_author_class($comment->comment_author_email,$comment->user_id)?>
<?php if(user_can($comment->user_id, 1)){echo \\”<a title=\\’博主认证\\’ class=\\’vip\\’></a>\\”;}; ?>
我们还需要添加样式:
.vp,.vip,.vip1,.vip2,.vip3,.vip4,.vip5,.vip6,.vip7{background: url(images/vip.png) no-repeat;display: inline-block;overflow: hidden;border: none;}
.vp{background-position:-515px -3px;width: 14px;height: 14px;margin-bottom: -2px;}
.vip{background-position:-495px -2px;width: 15px;height: 16px;margin-bottom: -3px;}
.vip1{background-position:-1px -2px;width: 46px;height: 14px;margin-bottom: -1px;}
.vip2{background-position:-63px -2px;width: 46px;height: 14px;margin-bottom: -1px;}
.vip3{background-position:-144px -2px;width: 46px;height: 14px;margin-bottom: -1px;}
.vip4{background-position:-227px -2px;width: 46px;height: 14px;margin-bottom: -1px;}
.vip5{background-position:-331px -2px;width: 46px;height: 14px;margin-bottom: -1px;}
.vip6{background-position:-441px -2px;width: 46px;height: 14px;margin-bottom: -1px;}
.vip7{background-position:-611px -2px;width: 46px;height: 14px;margin-bottom: -1px;}
这里,我们需要添加图片,配合样式中调用的图片(images/vip.png)。
这篇文章有参考:http://www.banyuner.com/7410.html
猜你可能想看的VPS
- 极光 KVM 五月优惠→美西双程 CN2_GIA 免费升级 189 年起日本VPS[主机]
- VIRPUS→$2 月 XEN-512MB 15GB 1.5TB 西雅图全球[VPS测评]
- soladrive→视频切片服务器等多用途 $395 40 核+80 超全球[VPS测评]
- 促销 死海网络→洛杉矶 CN2 GIA 线路月付直降 50 元 圣何塞不全球[VPS测评]
- Win7 系统 IIS 运行 asp 网站提示→ActiveX 部件不能全球[VPS测评]
- 网络好 $27 年 1G 内存 25G SSD 1T 流量@1Gbps 全球[VPS测评]
- GeorgeDatacenter→$15 年 1GB 内存 100GB 虚拟空间(主机)
- 真实测评 桔子 VPS→美国 Cera 洛杉矶数据中心 三网回程 CN2美国VPS[主机]
- MoonVM 香港 HKT HKBN 家宽 G 口 VPS 补货,原生动香港VPS[主机]
- 彩虹数据日本三网 GIA 云主机促销,去程直连回程 CN2,稳定低延迟,日本VPS[主机]
- 疯狂猜成语 图猜成语一个人在骂百和一是什么成语?全球[VPS测评]
- [国庆]KVMLA→日本 新加坡 KVM 主机 8 折+赠送内存日本VPS[主机]
- 补货 Virmach→$1.25 月低配套餐补货 512M 及以上套餐终全球[VPS测评]
- 如何规划博客写文章的流程,加快发文速度全球[VPS测评]
- 腾讯云岁末回馈老用户免费体验CDN,轻量应用服务器或者云存储一个月全球[VPS测评]
- anyNode黑五便宜VPS1G内存20g硬盘1g端口2T大流量年付仅8全球[VPS测评]
- WordPress网站代码实现网站弹窗广告全球[VPS测评]
- AlexHost摩尔多瓦抗投诉 VPS 云服务器 1.5G内存/不限流/全球[VPS测评]
- 如何为WordPress网站站外链接添加自动nofollow功能全球[VPS测评]
- HKServerSolution 4核心 4G内存 20G SSD 3T全球[VPS测评]
- 什么是云计算?全球[VPS测评]
- 什么是云服务器?云服务器怎么登陆?全球[VPS测评]
- 人力资源管理系统前端Web模板 - SmartHR全球[VPS测评]
- 奇维云优惠活动:香港CN21核1G1M带宽云服务器免费领取香港VPS[主机]
- 74块钱一年的云服务器可以用来做什么?全球[VPS测评]
- 群英云:新年促销活动,海外云服务器9.9元起,高防云服务器135元全球[VPS测评]
- jquery css3实现的进度条动画特效,带加载进度条百分比动态效果。全球[VPS测评]
- cmivps:全场7折,香港不限流量VPS,Windows系统,LinuWINDOWS
- HKserver:香港GIA VPS,1核/512MB/10GB空间/1虚拟空间(主机)
- 三优云uuuvps:春节促销,香港cn2 vps低至168元/年,多款配香港VPS[主机]
转载请注明原文地址:http://140.238.13.167:12355/read-142723.html











