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
- Sentris→$6.99 年 192MB 内存 15GB 空间 250虚拟空间(主机)
- 阿里云服务器拼团→低至 1.5 折起 2 核 1G 云服务器低至 148全球[VPS测评]
- 中日 IPLC 专线 VPS ¥120 月 512M 内存 10G H日本VPS[主机]
- HKBTELE→699 元 月 E3-1225 16G 内存 1TB 硬日本VPS[主机]
- NTUP→$20 月 2*L5420 8GB 内存 300GB SAS 全球[VPS测评]
- dedecms 默认文档点击数修改 dedecms 默认文档点击数范围全球[VPS测评]
- 疯狂猜成语 图猜成语一根签子上有三个丸子两边各有一个问号是什么成语?全球[VPS测评]
- 分享 OneDrive 多网盘挂载程序-CuteOne 安装教程全球[VPS测评]
- CloudCone→$1.8 月 KVM-512MB 10GB 1TB 全球[VPS测评]
- CSS 样式的优先级说明全球[VPS测评]
- DMIT 两周年大促→美国 cn2 vps 消费返余额+送实物 三折起!美国VPS[主机]
- 7 折优惠 $3.49 月 1G 内存 20G SSD 1T 流量 KV全球[VPS测评]
- 疯狂猜成语 图猜成语一根棍子打草旁边一条蛇是什么成语?全球[VPS测评]
- 今日头条欲做号内搜索,可搜站外不少内容全球[VPS测评]
- WordPress插件:SM.MS UPLOADER上传图片到SM.MS全球[VPS测评]
- 阿里云国际版香港机房轻量应用服务器VPS测评,三网联通AS4837,与新香港VPS[主机]
- 大前端 DUX 美化版主题推荐:QGG全球[VPS测评]
- ZJI 双十一 充值送 香港高防五折 阿里云香港线路立减270元香港VPS[主机]
- Connectindo → 9.9$ 月 2C1G20G硬盘 新加坡HE全球[VPS测评]
- GigsGigsCloud新加坡大陆优化VPS上架全球[VPS测评]
- wikihost,微基主机服务,100M带宽香港tudcloud,5G防香港VPS[主机]
- tmhhost:香港CN2/NNT,美国CN2 GIA VPS,韩国CN韩国VPS[主机]
- 香港云服务器怎么选?云服务器性能测评对比香港VPS[主机]
- “休闲养蜂”风靡海外跨境电商追逐垂直风口全球[VPS测评]
- JGKVM:1核/512M/30G/600G/30Mbps/洛杉矶CN2全球[VPS测评]
- Aoyohost:1核1GB/20GB/600GB流量/60Mbps端口香港VPS[主机]
- 腾讯云限时秒杀改版:轻量应用服务器2核4G8M仅598元/年,增香港/新香港VPS[主机]
- CMCUCT:2核2GB/20GB香港ntt线路vps 6TB流量/1G香港VPS[主机]
- 中久数据:2021新年特惠便宜挂机宝5元/月,香港1G仅20元/月,美国美国VPS[主机]
- 创新互联:免备案美国香港云主机4核2G仅558元/月,5580元/年美国VPS[主机]
转载请注明原文地址:http://140.238.13.167:12355/read-223189.html











