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
- Bacloud→€26.7 年-1GB 25GB 100M 无限流量 芝全球[VPS测评]
- SaltyfishTech→$13.9 季 1GB 内存 10GB SS虚拟空间(主机)
- 修罗云→165 元 季 512MB 内存 6GB 空间 1TB 流量 1虚拟空间(主机)
- 感恩节优惠 iON→美国洛杉矶机房 VPS 年付低至 4 折 2 核 2美国VPS[主机]
- bbr plus bbr 原版 bbr 魔改和锐速四合一脚本全球[VPS测评]
- 疯狂猜成语 图猜成语一片草和一个人被拦腰斩断是什么成语?全球[VPS测评]
- PuzCloud→103.2 元 季 1GB 内存 10GB 空间 50虚拟空间(主机)
- 生日优惠 OLVPS→国内外机房多重神秘优惠 洛杉矶安畅机房 CN2 G全球[VPS测评]
- ZetServers→€119 月 E3-1220v3 8GB 内存 2全球[VPS测评]
- 文件夹选项在哪?文件夹选项怎么打开?全球[VPS测评]
- HostKvm→$6.65 月 2GB 内存 20GB SSD 空间 6虚拟空间(主机)
- WordPress博客使用php页面代码实现外链go跳转的方法全球[VPS测评]
- quadranet机房 独立服务器买二赠一,3G DDoS高防,$39起独立服务器[U]
- WordPress知名主题DUX、JustNews、November、E全球[VPS测评]
- 咖啡主机元旦洛杉矶高防/香港将军澳VPS八折优惠,月付16元起香港VPS[主机]
- 恒创科技元旦 香港/美国VPS 2折起;高防服务器6折优惠美国VPS[主机]
- Cloudcone便宜VPS,洛杉矶MC机房,1Gbps带宽,年付9.9全球[VPS测评]
- 通过 IndexNow 将 WordPress 网站内容更新快速提交给搜全球[VPS测评]
- edv-network → 4.9€ 月 2C2G40G硬盘 2T流量 全球[VPS测评]
- JGKVM促销,美国cn2vps服务器价格再创新低,平均6.5元/月起美国VPS[主机]
- 跨境电商周报丨拼多多布局跨境电商平台;Shopify将推出新平台支持网红全球[VPS测评]
- JGKVM:1核/512M/30G/600G/30Mbps/洛杉矶CN2全球[VPS测评]
- 傲闪云vps,1核1G低至10元起,国内高防/香港CN2/美国CN2/美美国VPS[主机]
- 企鹅小屋:香港VPS限时3折优惠,香港沙田CN2,原生IP,年付486.香港VPS[主机]
- GreenCloudVPS:6折优惠,日本、新加坡、香港等KVM VPS日本VPS[主机]
- 快云科技:香港CN2VPS,2核/2GB内存/3M独享,仅售14.98元香港VPS[主机]
- gcorelabs:KVM主机€1.08/月起;俄罗斯/美国/香港/日本日本VPS[主机]
- 樊云:香港CN2节点vps,最低月付22.5起,带宽5Mbps起步香港VPS[主机]
- 用玩客云做打印服务器,让你在手机上轻松实现无线打印全球[VPS测评]
- kvmcloud怎么样?香港BGP云服务器 月付12.9元香港VPS[主机]
转载请注明原文地址:http://140.238.13.167:12355/read-222515.html











