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
- 疯狂猜成语 图猜成语一个袋子里面装着枪和头盔是什么成语?全球[VPS测评]
- 测评 酷番云→88 元 年云服务器测评数据 有条件的可以免费撸全球[VPS测评]
- STSDUST→30.55 元 月 384MB 内存 5GB 空间 50虚拟空间(主机)
- 最后三天RAKsmart→日本新品上 线 E5-2630L 仅售$99 日本VPS[主机]
- 便宜的免备案虚拟主机-Hostens 虚拟主机月付低至 0.99 美元全球[VPS测评]
- abelohost→100M 不限流量 VPS 无视版权 投诉 支持微信全球[VPS测评]
- QQ 空间被封怎么办?QQ 空间被封如何填写申诉解封?虚拟空间(主机)
- 特价 碳氧云→6 核 CPU 6G 内存 80G 硬盘 6Mbps 不限香港VPS[主机]
- porkbun - 域名注册.com 首年$5.95 .net 首年$6全球[VPS测评]
- 投稿 vpsms→洛杉矶安畅 GIA-CN2 机房上架新节点(提速版) 全球[VPS测评]
- iWFHosting→2G 内存 KVM 每月 8.99 美元 洛杉矶高全球[VPS测评]
- LOCVPS→日本大阪 65 折 XEN 双核 2G 30GB 5M 每日本VPS[主机]
- 绕的厉害-RivenCloud→爱沙尼亚 VPS 2 核 1G 内存 1全球[VPS测评]
- DogYun 德国(CN2) 香港(CMI)上线 支持小时计费 自助换 香港VPS[主机]
- 限时抢购 CloudCone→1G 内存 20G 硬盘 2T 流量年付$全球[VPS测评]
- 疯狂猜成语 图猜成语一个老人旁边一个红色的叉一个绿色的问号是什么成语?全球[VPS测评]
- AcroServers 波兰商家,全球38个节点,默认1Gbps带宽,€全球[VPS测评]
- RackNerd 三款AMD Ryzen便宜VPS限时促销,年付$18.全球[VPS测评]
- 轻量 PHP 单文件在线文件管理器推荐全球[VPS测评]
- HKServerSolution → 2G 内存 20G HDD 2T单全球[VPS测评]
- CrownCloud → 512M内存 500G HDD 3T流量 1G全球[VPS测评]
- Wikihost(idc.wiki) → 日本CN2 去程163回程C日本VPS[主机]
- on9host 1核心 512M内存 15G 储存 500G流量 30M全球[VPS测评]
- 缓解云计算人才焦渴,苏州工业园区用三年引得源头活水来全球[VPS测评]
- 什么是云计算?全球[VPS测评]
- 言車新车|大阳VPS125混动踏板,长续航,代步通勤9980元起全球[VPS测评]
- 什么是IconFont ?iconfont 的使用和解析全球[VPS测评]
- SugarHosts:虚拟主机三折起,VPS五折起,续费也可以享受优惠全球[VPS测评]
- RangCloud:山东BGP NAT VPS,19元/首月,大带宽VP香港VPS[主机]
- 影速科技怎么样?影速科技海外云服务器价格多少钱?全球[VPS测评]
转载请注明原文地址:http://140.238.13.167:12355/read-227798.html











