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
- AquaNX→圣何塞无限流量 VPS 月付 3.5 美元起 可选精品网 香港VPS[主机]
- 云霸天下 IDC 日本站群服务器促销,4C 段 253 个 IP,50M站群服务器[IP]
- 阿里云采购季→1C2G1M 低至年付 74 元 2C4G5M 云服务器 全球[VPS测评]
- 便宜 Hostsailor→256M 内存套餐$6.6 年 1G 内存月全球[VPS测评]
- 便宜 VPS $18 年 2 核 CPU 2G 内存 25G SSD 3全球[VPS测评]
- Error: php55w-common conflicts with 全球[VPS测评]
- 腾讯云采购季最后一天,云服务器低至 299 元 3 年,2 核 4G 4全球[VPS测评]
- [黑五]DediPath→VPS 全场 5 折 Hybrid Serve全球[VPS测评]
- 疯狂猜成语 图猜成语一张网一条河里面有一根针是什么成语?全球[VPS测评]
- 六六云→36 元 月 512MB 内存 15GB SSD 空间 1TB 虚拟空间(主机)
- AlphaVPS 黑五 1GB内存 2核CPU 1T流量 免费赠送DA面全球[VPS测评]
- robots.txt与nofollow之间的区别全球[VPS测评]
- HostEONS买AMD Ryzen+NVMe VPS送免费DirectWINDOWS
- 腾讯云岁末回馈老用户免费体验CDN,轻量应用服务器或者云存储一个月全球[VPS测评]
- 岚云 VPS 香港 CN2 GIA 线路 全程跑满 月付29.25元 还香港VPS[主机]
- YYYHost 香港沙田/洛杉矶Cera高防VPS 强制三网cn2gia香港VPS[主机]
- SafeNote 阅后即焚笔记分享服务全球[VPS测评]
- edgenat春节特惠 香港cn2/韩国cn2/洛杉矶高防cn2 月付七韩国VPS[主机]
- Wikihost → 香港沙田Gen3 → 1G 10G SSD 5香港VPS[主机]
- HostDoc 1核心 3G内存 30G SSD 60G HDD 1T流美国VPS[主机]
- 厘米云,江苏移动100G高防云服务器,4核4G内存20M带宽79元/月全球[VPS测评]
- Centos7的firewall 防火墙如何设置端口转发?全球[VPS测评]
- 2020年国外VPS哪个最好?教你学会选择国外VPS全球[VPS测评]
- jquery css3实现的进度条动画特效,带加载进度条百分比动态效果。全球[VPS测评]
- 紫云服务器怎么样?紫云香港云服务器1核1G2M仅65元/月香港VPS[主机]
- 众创逸云:国庆中秋节大促销优惠,不限流量香港CN2线路VPS 5.9元/香港VPS[主机]
- “休闲养蜂”风靡海外跨境电商追逐垂直风口全球[VPS测评]
- 极光KVM:1核/1G/40G/100Mbps/美国GIA,年付199元美国VPS[主机]
- 虾皮跨境电商怎么样?虾皮跨境电商靠谱吗?全球[VPS测评]
- 好朋友51WORLD启动“地球克隆计划5”,我要去元宇宙参加了全球[VPS测评]
转载请注明原文地址:http://140.238.13.167:12355/read-226473.html











