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
- 网络较差-SoftShellWeb→首月 0.01-0.02 美元 KV全球[VPS测评]
- dedecms 获取文章完整标题全球[VPS测评]
- 织梦 cmsTAG 标签显示每个标签共有多少篇文章全球[VPS测评]
- yum 提示 Error: rpmdb open failed 错误的解全球[VPS测评]
- tp5.1 怎么获取当前模块名 控制器名 方法名?全球[VPS测评]
- 劳动节便宜 CloudCone→1 核 1.5G 内存 45G 硬盘 1全球[VPS测评]
- ZJI→570 元 月-E5 2630L 16GB 480G SSD 5香港VPS[主机]
- nat.bz→108 元 月 384MB 内存 5GB SSD 空间 5虚拟空间(主机)
- 免费 KT 旗下 VPS 品牌 iON 免费送 14 天新加坡 VPS 全球[VPS测评]
- $86 月 E3 1230 16G 内存 1T 硬盘 10T 流量 1G全球[VPS测评]
- 做站首选 腾讯云服务器秒杀活动→上海机房 2G 内存 VPS 年付 19全球[VPS测评]
- 大前端 WordPress 主题 DUX 6.4 优化版 无限制 无后门全球[VPS测评]
- 青云互联 香港安畅 CN2GIA VPS八折优惠 1G内存/单核/5Mb香港VPS[主机]
- 5个整理博客旧文章的SEO观念全球[VPS测评]
- LetBox → 512M内存 11G NVMe储存+256G块储存 1全球[VPS测评]
- 阿里云轻量级服务器低至144年付全球[VPS测评]
- 持续高温!长沙所有初中新生停止军训!全球[VPS测评]
- 搬瓦工:美国香港cn2 gia线路VPS,10Gbps带宽,移动+联通企美国VPS[主机]
- HTML5绿色有机食品电商网站模板 - Organtio全球[VPS测评]
- 企鹅小屋怎么样?深港IPLC专线销售 500M大带宽/2核1G内存/55全球[VPS测评]
- 初忆云: 滁州电信、湖北电信云服务器价格低至10元起,续费同价全球[VPS测评]
- HTML5绿色有机食品电商网站模板 - Organtio全球[VPS测评]
- 云计算竞争日趋白热化云计算行业市场前景分析全球[VPS测评]
- UCloud全球大促活动:香港2核4G2M仅485元/年(台湾437元/美国VPS[主机]
- 企鹅小屋:香港VPS限时3折优惠,香港沙田CN2,原生IP,年付486.香港VPS[主机]
- 蓝米云:美国cera vps/香港cn2vps套餐,1核2G/40G/1美国VPS[主机]
- 7月份,经济复苏边际趋缓,央行降息幅度先稳后升全球[VPS测评]
- 腾讯云美国硅谷服务器/香港/新加坡:1核1G(Linux)云服务器仅28美国VPS[主机]
- 遨游主机:8折优惠,美国cn2 gia vps,54元/月,2G内存/1美国VPS[主机]
- SugarHosts,美国云服务器,洛杉矶cn2中美极速专线,香港建站服美国VPS[主机]
转载请注明原文地址:http://140.238.13.167:12355/read-224437.html











