WordPress根据最后一次评论时间判断是否显示评论者链接
![]() | ![]() | ![]() | ![]() |
| 【性价之王】 | 【线路之王】 | 【价格之王】 | 【配置之王】 |
| 【免费之王】 | 【香港首推】 | 【梯子之王】 | 【独服之王】 |

现在WordPress博客博主指不定哪天就不更新关站,域名也不续费被域名注册商收回释放。
有很多域名就会被做小视频或者小图片的人购买解析到某站,指不定评论者的网站挂了,被搞成了有害人身心健康的网站呢。
而为了防范这种情况,同时也增强博客网站的互动性,可以根据评论者最后一次评论时间来决定是否显示评论者链接。
比如,评论者的最后一次评论时间距离当前时间超过了 10 天,就禁止显示评论者网站链接。
直接function.php贴上代码:
function lxtx_show_comment_author_link( $return , $author, $comment_ID ){ if ( !is_user_logged_in() ) { // 登录用户无鸭梨 date_default_timezone_set('PRC'); $limit_days = 10; // 天数,代表最后一次评论时间距离今天超过10天的话,则隐藏评论链接 $comment = get_comment( $comment_ID ); if ( !empty($comment->comment_author_email) ) { $last_comment = get_comments(array( 'author_email' => $comment->comment_author_email, 'number' => '1', 'orderby' => 'comment_date', 'order' => 'DESC', 'status' => 'approve', 'type' => 'comment' )); if ( (time() - strtotime($last_comment->comment_date)) > $limit_days*24*3600 ) { $return = $author; } }else{ $return = $author; } } return $return;}add_filter('get_comment_author_link','lxtx_show_comment_author_link', 10, 3);当然,本方法仅适合使用 the_author_link()来输出评论者昵称的主题,一般来讲,标准主题都会使用这个函数。
[WordPress]历史优惠活动内容
猜你可能想看的VPS
- 腾讯云 - 云服务器精选秒杀 1 核 2G2M 三年付 680 元全球[VPS测评]
- nexusbytes→大硬盘 VPS $38 年 KVM 512m 内存全球[VPS测评]
- Krypt→ION 平台圣何塞节点上线 8 折优惠码 CN2 优化全球[VPS测评]
- 速抢 PacificRack 传家宝套餐限量销售→年付$10.88 1 全球[VPS测评]
- 来自 Discuz 的经典 php 加密&解密函数 AuthCode()全球[VPS测评]
- 华为云→国内 香港云服务器秒杀 CPU 独享 1 核 2G 起 最高 1香港VPS[主机]
- CN2 GT $20 年 512M 10G SSD 600G 流量 1G全球[VPS测评]
- 疯狂猜成语 图猜成语一根绳子上穿着一串写着恶字的金牌子是什么成语?全球[VPS测评]
- CloudCone→$14 年 512MB 内存 15GB 空间 2TB虚拟空间(主机)
- 腾讯云秒杀→AMD 云服务器年付 88 元起 2C4G3M 年付 368全球[VPS测评]
- [黑五]ITLDC→虚拟主机 2 折 VPS 四折 独立服务器 6 折 独立服务器[U]
- nginx 强制下载 txt 文件 nginx 禁止浏览器直接打开 tx全球[VPS测评]
- mysql ERROR 1017:Can't find file: ' 全球[VPS测评]
- 线路差-VIRPUS:$15.3 年 1.5T 流量 西雅图 VPS 3全球[VPS测评]
- php 中方法和函数的区别全球[VPS测评]
- 真实测评 六六云→洛杉矶三网双程 GIA1 核 1G 15G SSD 1全球[VPS测评]
- WordPress 插件:wpjam collection图片集对Wor全球[VPS测评]
- 在宝塔面板安装WordPress如何设置伪静解决404页面全球[VPS测评]
- 篱落主机 香港多线BGP VPS 黑五特惠 全场5折终身优惠码香港VPS[主机]
- Oneinstack一键开启安装ngx_lua_waf防火墙功能全球[VPS测评]
- 如何防止google voice被回收全球[VPS测评]
- 微信上线“好物圈”功能 可为朋友推荐商品全球[VPS测评]
- 使用 Classic Widgets 插件恢复 WordPress 原来全球[VPS测评]
- 50KVM 波特兰系列机型季付优惠活动全球[VPS测评]
- CloudCone 512M 内存 15G 储存 1T流量 洛杉矶 MC全球[VPS测评]
- DMIT 1核心 1G内存 10G SSD 1500G流量 100M带宽全球[VPS测评]
- 如何更改WHMCS默认后台路径让WHMCS系统更安全全球[VPS测评]
- 快速云:云服务器和vps区别是什么云服务器和vps哪个比较安全2022-全球[VPS测评]
- 兼容移动和PC的loading加载和toast消息插件全球[VPS测评]
- 宝塔面板在香港服务器安装启动不了nginx怎么办?香港VPS[主机]
转载请注明原文地址:http://140.238.13.167:12355/read-227810.html











