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
- invs→4.1 元 月 512MB 内存 5GB 空间 不限流量 10虚拟空间(主机)
- 百度云 - .COM 国际顶级域名新注册 45 元 首年全球[VPS测评]
- JQuey 中 each 方法怎么获取 判断 index?全球[VPS测评]
- 便宜 $2 月 512M 内存 10G SSD 1Gbps 不限流量 K全球[VPS测评]
- 便宜 RAKsmart→“抄底价 购实惠” 爆款 G 口 不限低至 19全球[VPS测评]
- Ubuntu 下通过 Wine 安装 uTorrent全球[VPS测评]
- ThinkPHP5 在 Nginx 下面报 404 错误的解决办法全球[VPS测评]
- 便宜 VPS $20 年 512M 内存 10G SSD 1Gbps 不全球[VPS测评]
- 疯狂猜成语 图猜成语五个人头上都有圆圈站在一起 旁边还有一个人头上也有圆全球[VPS测评]
- 9s9s→大带宽洛杉矶 CN2 GIA VPS 圣何塞不限流量 VPS 全球[VPS测评]
- 易探云 美国/香港/中国便宜VPS主机限时秒杀,最低218元一年和送QQ美国VPS[主机]
- CloudCone2021开年限时抢购 高IOPS/纯SSD硬盘/int全球[VPS测评]
- Contabo新增纽约和西雅图两个数据中心,免设置费,200G大硬盘VP全球[VPS测评]
- 2021搬瓦工日本软银JPOS_1机房测评,CN2扩容后移动/电信/联通日本VPS[主机]
- 网站配置HSTS协议的好处和必要性全球[VPS测评]
- 百度高速下载神器PanDownload2.0.6更新 功能更强大全球[VPS测评]
- HKServerSolution 七夕优惠汇总 香港 HKBN 8 折 香港VPS[主机]
- 2022年有哪些顶级托管服务提供商全球[VPS测评]
- 从阿里云七代云服务器,谈云计算四大趋势全球[VPS测评]
- 向日葵-漏洞科普:海外云服务器三种漏洞修复方法快收藏起来!全球[VPS测评]
- 精美的宠物医院网站WordPress主题 - Valkuta全球[VPS测评]
- 企鹅小屋:1核/512MB/10GB SSD空间/500GB流量/KVM虚拟空间(主机)
- HostKvm:韩国香港vps10月份最新促销,海外VPS全场八折优惠韩国VPS[主机]
- VPS到底有什么用?全球[VPS测评]
- 磐逸云:深圳/大连/成都/香港机房vps,1核1G3M仅26元/月,65香港VPS[主机]
- 六六云:美国cera机房CN2 GIA高防/香港CN2 GIA建站/CM美国VPS[主机]
- 疯鱼云怎么样?香港CN2VPS首月14元,续费19元香港VPS[主机]
- 快云科技:2核2G3M云服务器14.98元/月;香港vps全场7.5折,香港VPS[主机]
- 瓜云互联:香港CN2/美国洛杉矶高防vps优惠促销,预充款最高送300元美国VPS[主机]
- php168数据库配置文件在哪里?如何修改数据库配置文件全球[VPS测评]
转载请注明原文地址:http://140.238.13.167:12355/read-222328.html











