wordpress添加访客排行代码 自动实现最新评论排第一
![]() | ![]() | ![]() | ![]() |
| 【性价之王】 | 【线路之王】 | 【价格之王】 | 【配置之王】 |
| 【免费之王】 | 【香港首推】 | 【梯子之王】 | 【独服之王】 |

wordpress建站的可扩展性很强,除了有很多漂亮主题和可用插件之外。还可以用代码实现一些很酷的功能。
最近发现不少博客首页都增加了一个根据访客评论自动排名的功能,或者也有的站长称为“动态友链”的,目前没有统一的名称,但是可以大幅提高访客互动的积极性。
大部分站长都是用代码功能实现的。我也偷师了一下,给博客也增加一个访客排行榜。效果如图:
访客排行榜
这样一来,来访的站长评论后会自动更新排位,下面也分享出修改方法。
延伸阅读:begin主题添加《英雄榜》每评论一次你就会自动排第一代码
内容 1 1、将下面这段代码添加到自己主题的function.php文件后面: 2 2、将下面代码添加到网站首页文件中,位置可以自己选择: 3 相关文章1、将下面这段代码添加到自己主题的function.php文件后面:
//2019年1月24日添加访客榜单function getvisitors() { global $wpdb; // $query="select * from `wp_comments` where `comment_approved`=1 group by `comment_author_url` order by comment_ID DESC limit 0,12"; $query="select MAX(`comment_ID`) comment_ID ,`comment_author_url`,`comment_author` from wp_comments where `comment_author_url`<>'' and `comment_author_url` not like '%zouaw%' and `comment_approved`='1' group by `comment_author_url` order by `comment_ID` DESC limit 0,23;"; $sql = $wpdb -> get_results($query, ARRAY_A); //print_r($sql);foreach($sql as $vales){ echo "<li><img src='https://www.chukuangren.com/wp-content/uploads/2019/01/timg-1.gif'><a target='_blank' rel='nofollow' h=".$vales["comment_author_url"].">".$vales["comment_author"]."</a></li>"; }}2、将下面代码添加到网站首页文件中,位置可以自己选择:
<div class="vistor"><style> .vistor{width:100%;margin-bottom:20px;height:auto!important;background:#fff;border:1px solid #f5f9ff;text-align:center;color:#096cb2;border:1px solid #eaeaea;border-radius:4px;}.vistor p{padding-top:4px;font-size:17px;}.vistor ul{margin-top:10px;margin-bottom:10px;font-size:13px;padding-bottom:40px;}.vistor ul li{list-style:none;float:left;margin-left:0px;margin-bottom:10px;width:16.6%;overflow:hidden;height:20px;text-align:left;}.vistor ul li img{width:20px;height:20px;margin-left:2px;margin-right:2px;}@media (max-width:820px) { .vistor ul li{width:25%;font-size:9px;} .vistor p{padding-top:4px;font-size:15px;} }</style><p><a h="/visitor-html" target="_blank">[访客榜单]-</a>每评论一次你就会自动排第一位</p><ul><li><img src='https://www.chukuangren.com/wp-content/uploads/2019/01/timg-1.gif'><a target='_blank' rel='nofollow' h=https://promotion.aliyun.com/ntms/yunparter/invite.html?userCode=0a5rig7f>阿里云主机</a></li><?php getvisitors();?></ul><div style="clear: both;display:block"> </div></div>那个转的蓝色图标是个GIF图片,大家也可以下载到本地,上传到自己网站使用!
[WordPress]历史优惠活动内容
猜你可能想看的VPS
- 企鹅小屋→香港 CN2 虚拟主机 独立 IP 不限绑定域名 6GB 空间虚拟空间(主机)
- [黑五]CMIVPS 全站 VPS 年付 6 折 半年付 7 折 独立服独立服务器[U]
- QSVM→新加坡 KVM VPS 可选限制流量或不限流量;256MB 内全球[VPS测评]
- 价格过高-Wired Blade→$5 月 2GB 内存 20GB NV虚拟空间(主机)
- 自行测试-Ransom IT→$21 季 1GB 内存 50GB SSD虚拟空间(主机)
- TmhHost→400 元 月 X3450 8GB 内存 240GB S香港VPS[主机]
- ITLDC - 保加利亚主机商 8 数据中心可选全球[VPS测评]
- 2019 年 5 月 Vultr 方案调整消息 免费增加硬盘 取消 51全球[VPS测评]
- hkserversolution→51 优惠 美国大带宽 cn2 gia美国VPS[主机]
- [黑五]DediPath→VPS 全场 5 折 Hybrid Serve全球[VPS测评]
- 新商家慎重-伏羲主机(6le)香港 cera 机房便宜 VPS 主机 1香港VPS[主机]
- ¥34 月 2G 内存 30G SSD 2Mbps 不限量 Xen 香港香港VPS[主机]
- 真实测评 CombCloud 香港沙田 CN2- 4H4G 80GSSD香港VPS[主机]
- hosteons→免费提供 Windows 授权 8 折优惠 $36 年WINDOWS
- MySQL 判断字段是否为 Null全球[VPS测评]
- $5 月 2CPU 512M 内存 12G SSD 1.5T 1Gbps全球[VPS测评]
- 禁止 layer.msg()在回调时抖动全球[VPS测评]
- 虎字下面的几变成一个口中间有个羊字是什么成语?全球[VPS测评]
- 在博客中如何合理展示AdSense 广告全球[VPS测评]
- 比TinyPNG好用的Squoosh在线图片压缩全球[VPS测评]
- 浅谈博客运营前、中、后期如何实现盈利全球[VPS测评]
- 谨慎使用 WPJAM BASIC、WP China Yes 之类的 Wo全球[VPS测评]
- CloudIPLC 沪日IPLC → 老牌稳定可靠IPLC全球[VPS测评]
- MoonVM,香港HKT家宽VPS服务器,动态IP一键切换,1G带宽任意香港VPS[主机]
- 好朋友51WORLD启动“地球克隆计划5”,我要去元宇宙参加了全球[VPS测评]
- 酷锐云双十一活动:美国vps、香港vps云主机,2核4G4M,50元/首美国VPS[主机]
- 吸血鬼崛起服务器怎么快速搭建?全球[VPS测评]
- 私有云架设之优选拓普龙S465-24高密度存储服务器机箱评测解析全球[VPS测评]
- HostHatch:1核/2GB/20GB空间/KVM/香港/洛杉矶/纽虚拟空间(主机)
- 云基:香港/洛杉矶CN2 GIA服务器促销,3750元/月起;欧洲大盘鸡香港VPS[主机]
转载请注明原文地址:http://140.238.13.167:12355/read-223426.html











