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 GIA VPS 补货→DC6 1 核 512M 全球[VPS测评]
- 腾讯云双十一提前购→1C2G1M 年付 88 元 2C4G5M 三年仅 全球[VPS测评]
- 腾讯云→国内云服务器年付 99 元起 单核 2G2M 三年仅 680 元全球[VPS测评]
- php 生成随机颜色最简单办法 php 一句话代码生成随机颜色全球[VPS测评]
- GigsGigsCloud 日本 cn2 gia vps 仅$7.3 起日本VPS[主机]
- RAKsmart 日本机房新品上线 E5-2630 L 仅售$99 I3日本VPS[主机]
- Laravel→SQLSTATE[42000]: Syntax erro全球[VPS测评]
- 便宜 $12.94 年 512M 内存 10G SSD 1T 流量@1G全球[VPS测评]
- BudgetVM→$10 月 1 核独享 2GB 内存 50GB SSD虚拟空间(主机)
- ExCloud→深港 IPLC 沪日 IPLC 等 VPS 256MB 全球[VPS测评]
- OVZ 的别买-HostMayo→$2 月 512M 内存 2T 流量 美国VPS[主机]
- 双立人一个闺一个寺是什么成语?全球[VPS测评]
- 加速云→四川德阳高防 525 元 16 核 16g 内存 200gSSD全球[VPS测评]
- Centos 复制文件夹内所有文件到另一个文件夹命令全球[VPS测评]
- azvds→$1.3 月 1GB 内存 10GB NVME 空间 不限流虚拟空间(主机)
- HostKvm香港 VPS/4G内存/20M带宽/CN2+BGP线路,下香港VPS[主机]
- WordPress保护后台登录插件:Login LockDown全球[VPS测评]
- 建站云服务器选择高效云盘还是SSD硬盘?全球[VPS测评]
- EIRSINT → 1.5$ 月 土耳其 1C2G25G硬盘 1Gbps全球[VPS测评]
- CubeCloud 新年促销 75 折全球[VPS测评]
- 长三角地区的算力需求规模到底有多大?全球[VPS测评]
- 六一云:香港CMI VPS,10G防御,1核/1G/40G SSD/15香港VPS[主机]
- 者也IO,香港日本美国云服务器促销,2核2G1000元/2年,7折+内存日本VPS[主机]
- 企鹅小屋:深港IPLC节点,0.25元/G流量,不用不花钱全球[VPS测评]
- 恒创科技:国庆中秋双节同庆,香港1核2G云服务器,年付378元香港VPS[主机]
- 腾讯云香港服务器优惠价格:4核8G5M新用户1508元,老用户2639元香港VPS[主机]
- 极光kvm怎么样,便宜大带宽香港cmi vps/美国gia vps低至1美国VPS[主机]
- uuuvps:香港大带宽vps低至239元/年;香港服务器720元/e3香港VPS[主机]
- 恒创科技:香港免备案CN2线路VPS/美国CN2直连VPS,月付28元起美国VPS[主机]
- ucloud云服务器全球购:香港/韩国/日本/台湾/越南/泰国服务器最低日本VPS[主机]
转载请注明原文地址:http://140.238.13.167:12355/read-224862.html











