- 资源介绍
- 更新记录
- 安装教程
RiPro日主题添加评论之星VIP等级
看到不少朋友都添加了评论之星,也就是按照评论的数量,设定评论等级,如下图所示:

![]()

网上也有教程,本次使用的主题是RiPro日主题。
1.在主题的 functions.php 添加下面的代码:
/**
* WordPress 添加评论之星等级
* https://www.zkww.site/
*/
function get_author_class($comment_author_email,$user_id){
global $wpdb;
$author_count = count($wpdb->get_results(
“SELECT comment_ID as author_count FROM $wpdb->comments WHERE comment_author_email = ‘$comment_author_email’ “));
/*如果不需要管理员显示VIP标签,就把下面一行的 // 去掉*/
// $adminEmail = get_option(‘admin_email’);if($comment_author_email ==$adminEmail) return;
if($author_count>=10 && $author_count<20)
echo ‘<a class=”cvip1″ title=”星海达人 LV.1″></a>’;
else if($author_count>=20 && $author_count<40)
echo ‘<a class=”cvip2″ title=”星海达人 LV.2″></a>’;
else if($author_count>=40 && $author_count<80)
echo ‘<a class=”cvip3″ title=”星海达人 LV.3″></a>’;
else if($author_count>=80 && $author_count<160)
echo ‘<a class=”cvip4″ title=”星海达人 LV.4″></a>’;
else if($author_count>=160 && $author_count<320)
echo ‘<a class=”cvip5″ title=”星海达人 LV.5″></a>’;
else if($author_count>=320 && $author_count<640)
echo ‘<a class=”cvip6″ title=”星海达人 LV.6″></a>’;
else if($author_count>=640)
echo ‘<a class=”cvip7″ title=”星海达人 LV.7″></a>’;
}
2.打开RiPro日主题的评论文件(一般在\ripro\inc\theme-functions.php里)(一般在1565行左右),找到:
printf( ‘<cite class=”%s”><i class=”fa fa-diamond”></i> %s</cite>’,$vip_name_class ,$CaoUser->vip_name().’ ‘.get_comment_author_link() );
3.在下一行添加
get_author_class($comment->comment_author_email,$comment->user_id); if($comment->user_id == 1){echo “<a title=’博主’ class=’cvip’></a>”;};
4.下载下面的图片,添加到主题的 images文件夹

5.在主题的样式diy.css/ 其他主题style.css 文件的最后,添加下面的样式代码:
.cvp,.cvip,.cvip1,.cvip2,.cvip3,.cvip4,.cvip5,.cvip6,.cvip7{background: url(../images/vip.png) no-repeat;display: inline-block;overflow: hidden;border: none;}
.cvp{background-position:-515px -2px;width: 16px;height: 16px;margin-bottom: -3px;}
.vp:hover{background-position:-515px -22px;width: 16px;height: 16px;margin-bottom: -3px;}
.cvip{background-position:-494px -3px;width: 16px;height: 14px;margin-bottom: -2px;}
.cvip:hover{background-position:-494px -22px;width: 16px;height: 14px;margin-bottom: -2px;}
.cvip1{background-position:-1px -2px;width: 46px;height: 14px;margin-bottom: -1px;}
.cvip1:hover{background-position:-1px -22px;width: 46px;height: 14px;margin-bottom: -1px;}
.cvip2{background-position:-63px -2px;width: 46px;height: 14px;margin-bottom: -1px;}
.cvip2:hover{background-position:-63px -22px;width: 46px;height: 14px;margin-bottom: -1px;}
.cvip3{background-position:-144px -2px;width: 46px;height: 14px;margin-bottom: -1px;}
.cvip3:hover{background-position:-144px -22px;width: 46px;height: 14px;margin-bottom: -1px;}
.cvip4{background-position:-227px -2px;width: 46px;height: 14px;margin-bottom: -1px;}
.cvip4:hover{background-position:-227px -22px;width: 46px;height: 14px;margin-bottom: -1px;}
.cvip5{background-position:-331px -2px;width: 46px;height: 14px;margin-bottom: -1px;}
.cvip5:hover{background-position:-331px -22px;width: 46px;height: 14px;margin-bottom: -1px;}
.cvip6{background-position:-441px -2px;width: 46px;height: 14px;margin-bottom: -1px;}
.cvip6:hover{background-position:-441px -22px;width: 46px;height: 14px;margin-bottom: -1px;}
.cvip7{background-position:-611px -2px;width: 46px;height: 14px;margin-bottom: -1px;}
.cvip7:hover{background-position:-611px -22px;width: 46px;height: 14px;margin-bottom: -1px;}
猜你喜欢
-
dynamic_sidebar()函数和is_dynamic_sidebar()函数
2021-04-26 -
RiPro主题美化之如何实现网页弹幕
2021-04-24 -
【WordPress插件】Media folder汉化版-媒体文件夹-v5.1.2
2021-04-24 -
Adobe Photoshop CC 2020 – MAC V21.0.1 & WIN V21.0.1.47 中文破解版 照片、UI、平面全能工具
2021-04-25 -
RIPRO修改-菜单增加角标
2021-04-24 -
WordPress纯代码实现图片灯箱lightbox效果
2021-04-25 -
wordpress修改wp-admin隐藏后台管理登录地址确保WordPress网站后台安全
2021-04-25 -
WordPress打赏/点赞/分享插件
2021-04-24 -
免费分享一款免费的素材管理工具Billfish
2021-04-25 -
WP获取分类的二级分类
2021-04-26
-
is_tax()函数
2021-04-26 -
WordPress如何在父分类获取所有子分类/二级分类
2021-04-25 -
Respawn – 电子游戏竞技网站WordPress主题 – v1.3
2021-04-24 -
xydown下载插件 移植美化版V2.0
2021-04-24 -
Ripro主题美化-添加shortcodes简码功能
2021-04-24 -
网站源码后门木马查杀软件 让你轻轻松松去掉后门
2021-04-25 -
RIPRO主题美化-文章添加公众号引流关注模块
2021-04-25 -
Ripro美化-添加用户活跃模块
2021-04-25 -
仿虾米音乐CMS主题 WordPress主题模板
2021-04-22 -
WordPress免插件配置SMTP邮件功能教程
2021-04-25
猜你在找
常见问题FAQ
- 免费下载或者VIP会员专享资源能否直接商用?
- 本站所有资源版权均属于原作者所有,这里所提供资源均只能用于参考学习用,请勿直接商用。若由于商用引起版权纠纷,一切责任均由使用者承担。更多说明请参考 VIP介绍。
- 提示下载完但解压或打开不了?
- 找不到素材资源介绍文章里的示例图片?
- 大资源
- 2021-04-25Hi,初次和大家见面了,请多关照!

