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
- 稳定 搬瓦工 DC6 机房 CN2 GIA 线路 512M 套餐 年付 全球[VPS测评]
- 极光 KVM→美国洛杉矶 Psychz KVM 19.8 元 月 续费同美国VPS[主机]
- jQuery 清空 input 值的方法全球[VPS测评]
- 腾讯云秒杀→上海云服务器年付 99 元起 2C84G4M 三年 948 全球[VPS测评]
- 搬瓦工 CN2 GIA 线路 DC6 补货 年付 46.8 美元全球[VPS测评]
- javascript 除法结果取整的四种方法全球[VPS测评]
- 便宜 VPS $15 年 512M 内存 8G SSD 1T 流量 1G全球[VPS测评]
- Skynode→€19 月 i3-2120 16G 内存 1TB 硬盘 全球[VPS测评]
- AlphaVPS→€9.95 月 OpenVZ-1GB 10GB 600全球[VPS测评]
- Buyvm→$2 月 512MB 内存 10GB SSD 空间 不限流量虚拟空间(主机)
- 香港直连 ¥432 年 2 内存 30G 硬盘 300G 流量 30Mb香港VPS[主机]
- STSDUST→$51.48 年 1GB 内存 20GB SSD 空间 虚拟空间(主机)
- servaRICA→$15 月 3 核 3GB 内存 2TB 空间 不限虚拟空间(主机)
- 优惠 iON→Krypt 旗下品牌 2G 内存 VPS 终身 5 折优惠全球[VPS测评]
- 便宜 $15 年 2 核 CPU 2G 内存 50G SSD 5T 流量全球[VPS测评]
- WebHorizon 波兰机房便宜vps,基于kvm,0.5G内存,£1全球[VPS测评]
- WordPress删除文章时怎么才能删除缩略图及图片附件全球[VPS测评]
- 使用Win10系统原生“截图工具”捕获屏幕快照 简单高效全球[VPS测评]
- WordPress网站引入腾讯vConsole调试面板方便手机端页面调试全球[VPS测评]
- Veda Web Host → 20$ 月起 1T流量100M端口 泰国全球[VPS测评]
- CrownCloud → 512M内存 500G HDD 3T流量 1G全球[VPS测评]
- 2019黑五: ZeptoVM 欧洲CN2 → 1C 512M RAM 全球[VPS测评]
- 8K超高清记录中国空间站凌月:天和核心舱与问天实验舱组成“土”字结构虚拟空间(主机)
- 跨境贸易和跨境电商的三大区别简单分析全球[VPS测评]
- 二三互联,香港cn2云服务器5折+85折双重优惠,稳定不限流量,1核1G香港VPS[主机]
- 适合美容院的正能量抖音文案,唯美阳光,正能量满满全球[VPS测评]
- 汇速云:香港沙田CN2云主机,2核CPU带宽1M月付6元,2核2M带宽月香港VPS[主机]
- 魔方云cubecloud:香港CN2VPS/美国CN2VPS终身88折/美国VPS[主机]
- Mysql连接数过高,如何检查?全球[VPS测评]
- LOCVPS:香港vps八折优惠中,双十一预热,充值充600送150,六香港VPS[主机]
转载请注明原文地址:http://140.238.13.167:12355/read-223189.html











