现在国家倡导各大网络平台要显示IP地址,目前各大厂都已经开始实行了,比如抖音,微博,今日头条等等,前几天讲了Zblog php评论如何实现IP地址的,今天再教一下大家如何用wordpress的子比主题评论显示IP地址,大家可以举一反三进行操作。

一,先下载安装包

下载以后把安装包 上传到WordPress站点下面… 注意不是主题下面

https://dtmb.lanzouy.com/icdMd0fwqp4d

二,替换代码

加入function.php
include("ip2c/ip2c.php"); //IP 归属地和运营商查询功能
include("show-useragent/show-useragent.php");  //显示访客信息

/wp-content/themes/zibll/inc/functions/zib-comments-list.php 51行的 return '<name class="flex ac flex1">

替换代码

$ip = convertip(get_comment_author_ip());
    return '<name class="flex ac flex1">' . $user_name . $badge .'<span class="badg badge badg-sm flex0 ml3">'.$ip.'</span>'.'</name>';


然后 搜索 $time_html 在第一个 //时间  直接替换 代码
$diqu =  CID_get_comment_browser();
$diqu .= CID_print_comment_flag();
$time_html = '<span class="comt-author"' . ($is_mobile ? ' data-toggle="tooltip"' : '') . ' title="' . date('Y年m月d日 H:i:s', strtotime($comment->comment_date)) . '">' . zib_get_time_ago($comment->comment_date) . '</span>'.'<span class="comt-author" title="">'.$diqu.'</span>';

效果如下:

这样简单操作即可实现,本文使用的是下载下来IP地址库,存放到自己网站下面,这样在调用数据时,能非常快的调用数据,比使用API端口调用速度有比较大的优势。