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
- 高速 tmhhost→1G 1 核 20G 15M 1T 流量 季付¥9全球[VPS测评]
- 线路不行-Sentris→$24.99 3 年 512MB 内存 20G虚拟空间(主机)
- 企鹅小屋→香港 CMI CN2 KVM VPS 256MB 内存 200香港VPS[主机]
- 7 折活动 $1.4 月 512M 内存 1T 月流量 100M 带宽全球[VPS测评]
- $1 首月 4CUP 24G 内存 120G 硬盘 12TB 流量 1I全球[VPS测评]
- 大流量 $25 年 2G 内存 20G SSD 5TB 流量@1Gbps全球[VPS测评]
- AkkoCloud→99 元 月 1GB 内存 10GB SSD 空间 虚拟空间(主机)
- UEditor 赋值 html 数据无法按照原来样式显示怎么办?全球[VPS测评]
- 体验 Google AdSense 广告联盟的链接广告样式全球[VPS测评]
- 引力主机双12九折优惠安徽联通NATVPS1G内存4T大流量200M大带全球[VPS测评]
- 如何合理地设置WordPress文章延伸阅读或文章超链接全球[VPS测评]
- WordPress插件:WP Downgrade降级到旧版本或者升级到新全球[VPS测评]
- 搬瓦工vps实时库存检测aff网站程序,全自动检测搬瓦工vps实时库存全球[VPS测评]
- RaiolaNetworks → 9.9€ 月 1C1G10G 100M全球[VPS测评]
- Cloudzone → 越南 2.99$ 月 1C0.5G20G硬盘 5全球[VPS测评]
- Webuphosting-西班牙 2€ 月 1G内存10G硬盘 不限流量全球[VPS测评]
- Spry servers-凤凰城 月付$2.5 1核512M内存5G硬盘全球[VPS测评]
- 修罗云上海CN2 NAT → 1核 512M内存 6G硬盘 单向1T 7全球[VPS测评]
- Rustrot-深绿色UI电商网站模板HTML5框架全球[VPS测评]
- 云计算竞争日趋白热化云计算行业市场前景分析全球[VPS测评]
- 企鹅小屋:香港ntt vps,大带宽直连,1核/1G/2T流量/半年15香港VPS[主机]
- 中概股扫描网传拼多多正筹备跨境电商平台首站登陆美国美国VPS[主机]
- 好朋友51WORLD启动“地球克隆计划5”,我要去元宇宙参加了全球[VPS测评]
- 阳帝云:新年快乐666个现金优惠券,香港CN2 GIA、美国CN2高防V美国VPS[主机]
- 纳米云怎么样?纳米云香港vps,4核1G主机价格80元/月香港VPS[主机]
- 中久数据:2021新年特惠便宜挂机宝5元/月,香港1G仅20元/月,美国美国VPS[主机]
- 快速云:科普云服务器服务器的概念和作用2022-08-2313:26来源全球[VPS测评]
- 明恒互联:双旦同庆活动开启,100G国内高防云售价116元/月,香港云主香港VPS[主机]
- 加拿大以“国安”为由禁止华为、中兴参与5G建设全球[VPS测评]
- 2021年UCloud云服务器价格表,UCloud全球云主机租用报价表全球[VPS测评]
转载请注明原文地址:http://140.238.13.167:12355/read-223713.html











