WordPress无真人电一分钟了解ag真人在线注册子游艺投注插件外部链接自动添加nofollow标签
严格要求的话是需要在外部链接全部加上nofollow标签。当然目前一些wordpress主题设置有这个nofollow标签功能。当然我们也可以通过代码实现无插件添加方法。
在技术层//文章自动nofollowadd_filter( 'the_content', 'tin_seo_wl');function tin_seo_wl( $content ) { $regexp = "<a\s[^>]*href=(\"??)([^\" >]*?)\\1[^>]*>"; if(preg_match_all("/$regexp/siU", $content, $matches, PREG_SET_ORDER)) { if( !empty($matches) ) { $srcUrl = get_option('siteurl'); for ($i=0; $i < count($matches); $i++) { $tag = $matches[$i][0]; $tag2 = $matches[$i][0]; $url = $matches[$i][0]; $noFollow = ''; $pattern = '/target\s*=\s*"\s*_blank\s*"/'; preg_match($pattern, $tag2, $match, PREG_OFFSET_CAPTURE); if( count($match) < 1 ) $noFollow .= ' target="_blank" '; $pattern = '/rel\s*=\s*"\s*[n|d]ofollow\s*"/'; preg_match($pattern, $tag2, $match, PREG_OFFSET_CAPTURE); if( count($match) < 1 ) $noFollow .= ' rel="nofollow" '; $pos = strpos($url,$srcUrl); if ($pos === false) { $tag = rtrim ($tag,'>'); $tag .= $noFollow.'>'; $content = str_replace($tag2,$tag,$content); } } } } $content = str_replace(']]>', ']]>', $content); return $content;}
添加到当前主题Funcions.php 文件中,有时内容会引用或分享一些外部链接地址,可以直接找一些wordpress插件安装。$$$$$
- 最近发表
- 随机阅读
-
- 小米户外摄像头大升级:500万像素3K画质,高清看得见,199元带回家
- 小米米家推出折叠偏光近视太阳镜,轻巧便携又护眼,仅售199元!
- 织梦dedecms文章内容如何批量替换
- javascript位运算符与赋值运算符
- AR眼镜市场风向标:雷鸟创新打破垄断,新品X3 Pro引领行业新潮流
- 35dir网站分类目录源码v2.2(纯净版)
- 35dir网站分类目录源码v2.2(纯净版)
- 多功能二维码在线生成网站源码
- 石头P20 Pro 上下水版,18500pa吸力再降2248元,真实力更实惠
- wordpress时光轴自适应主题jinsomB模板
- SEO网站优化之URL的写法
- These Crypto Assets Dumped the Most as the Total Market Cap Shed Over $200B (Weekend Watch)
- wordpress提示function.call
- Adobe Dreamweaver cc 2018中文版本
- javascript一元运算符与算术运算符
- wordpress/帝国cms配置https(SSL)无法登录后台
- 站长搭建个人博客网站的N个理由
- 阿里云虚拟主机SSL证书部署(https配置)
- javascript网页mp3音乐播放器列表代码
- 分类目录缩略图自动截图/生成api有哪些
- 搜索
-
- 友情链接
-