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
- 便宜域名 Name→US 等 5 种域名 1.99 美元 年 CO 等 全球[VPS测评]
- php 怎么从文件路径中获取文件名 php 怎么从文件路径中分离文件目录全球[VPS测评]
- 限量特价 $1.49 每月 256M 内存 10G 硬盘 1T 流量 洛全球[VPS测评]
- 分享 Virmach 优惠码使用及 VPS 购买图文教程全球[VPS测评]
- Directory Listing Denied全球[VPS测评]
- 推荐 中小型企业怎么选择云服务器和 VPS 企业买 VPS 那里比较好!全球[VPS测评]
- 便宜 $3.5 月 2 核 CPU 4G 内存 75G SSD 2Gbp全球[VPS测评]
- 绕的厉害-RivenCloud→爱沙尼亚 VPS 2 核 1G 内存 1全球[VPS测评]
- WordPress 插件:wpjam collection图片集对Wor全球[VPS测评]
- RackNerd多IP站群服务器促销,季付$140起;多C段SEO站群服站群服务器[IP]
- 咖啡主机元旦洛杉矶高防/香港将军澳VPS八折优惠,月付16元起香港VPS[主机]
- CWVPS(cheapwindowsvps)美国高配 windows vWINDOWS
- DeepVM 西雅图4837高防VPS八折优惠,月付20元起;洛杉矶99全球[VPS测评]
- all-domains → 2€ 月 德国 1C1G20G硬盘 不限流量全球[VPS测评]
- HOSTIFY → 11$ 月 越南 2C2G50G硬盘 100M不限流全球[VPS测评]
- HKServerSolution → 4G内存 50G SSD 100M全球[VPS测评]
- 2019黑五: Krypt ION- 2C 2G RAM 60G SSD全球[VPS测评]
- jquery css3实现的进度条动画特效,带加载进度条百分比动态效果。全球[VPS测评]
- 如何设置指定路径跳转指定域名?全球[VPS测评]
- 跨境电商平台首选香港服务器香港VPS[主机]
- wikihost,微基主机:1核/1G/15G/100Mbps/香港vp香港VPS[主机]
- Weebly网站迁移到WordPress的实操上手。全球[VPS测评]
- 亿速云香港服务器助力企业出海 有哪些具体的特点和优势?香港VPS[主机]
- 企鹅小屋:深港IPLC节点,0.25元/G流量,不用不花钱全球[VPS测评]
- 详细介绍vps云服务器及其作用全球[VPS测评]
- 牛信云入选艾瑞《2022年中国跨境电商服务行业趋势报告》典型厂商全球[VPS测评]
- 奇维云优惠活动:香港CN21核1G1M带宽云服务器免费领取香港VPS[主机]
- 品光网络怎么样?香港美国服务器/云/高防,开年采购3.5折起美国VPS[主机]
- 好云:国内云服务器2核2G5M优惠,仅350元/年;香港/海外云服务器,香港VPS[主机]
- UOVZ怎么样?香港30M大带宽VPS 直连线路月付50元香港VPS[主机]
转载请注明原文地址:http://140.238.13.167:12355/read-223426.html











