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
- FDCServers→$1999 月 2*E5-2650 128GB 内日本VPS[主机]
- CPU 较差-GeorgeDatacenter→$3 月 2GB 内存 虚拟空间(主机)
- 扫米工具→未注册域名批量查询全球[VPS测评]
- 禁止浏览器自动填充 input 用户名密码全球[VPS测评]
- ThinkPHP5 输出最后执行的 sql 语句全球[VPS测评]
- MoonVM→$30 月 1GB 内存 10GB SSD 空间 3TB 虚拟空间(主机)
- [黑五]VIRPUS 三折→西雅图 XEN VPS 月付 1.5 美元起全球[VPS测评]
- sharktech→60G 高防服务器(物理机) $99 月 1Gbps全球[VPS测评]
- php 多个数组根据指定键值分组方法全球[VPS测评]
- 美国原生 IPVPS 解锁 Netflix Hulu_ 桔子 VPS 5美国VPS[主机]
- 如何将typecho转换到WordPress?全球[VPS测评]
- 知更鸟Begin主题代码实现外链转内链并base64加密全球[VPS测评]
- CommentBox.io 无广告、不追踪隐私的网站留言系统 WordP全球[VPS测评]
- Fatal error: Allowed memory size of 全球[VPS测评]
- 8K超高清记录中国空间站凌月:天和核心舱与问天实验舱组成“土”字结构虚拟空间(主机)
- 什么是云服务器?云服务器怎么登陆?全球[VPS测评]
- Bloggar-移动端友好的新闻博客类HTML5模板全球[VPS测评]
- 邢志宏:加快推动高质量建设跨境电商综试区起势成势全球[VPS测评]
- 阳帝云双十二活动:1核1G10M大宽带香港BGP云服务器,月付14元香港VPS[主机]
- 野草云服务器怎么样?香港CN2+BGP带宽30M月付19元香港VPS[主机]
- 中概股扫描网传拼多多正筹备跨境电商平台首站登陆美国美国VPS[主机]
- 免备案服务器对权重和网站排名有影响吗?全球[VPS测评]
- wikihost,微基主机服务,100M带宽香港tudcloud,5G防香港VPS[主机]
- 如何设置必应api 自动推送网站全球[VPS测评]
- 创意IT服务公司主页网站模板 - Softets全球[VPS测评]
- 麻花云双12活动:香港CN2云主机首月9元;安徽移动vps月付29元香港VPS[主机]
- 恒星云:高防服务器优惠活动,成都高防云服务器及辽宁香港服务器特惠活动香港VPS[主机]
- 企鹅小屋:香港VPS限时3折优惠,香港沙田CN2,原生IP,年付486.香港VPS[主机]
- uuuvps:香港VPS低至97元/年,CN2+bgp网络,香港机房VP香港VPS[主机]
- CentOS 7.x 系统安装和配置redis-7.0.4集群全球[VPS测评]
转载请注明原文地址:http://140.238.13.167:12355/read-225886.html











