WordPress无游戏接单平台app插庄闲的80%赢法件外部链接自动添加nofollow标签
严格要求的话是需要在外部链接全部加上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 文件中,这样所有的外部链接就会自动加上nofollow标签。当然目前一些wordpress主题设置有这个nofollow标签功能。
- 最近发表
- 随机阅读
-
- 首款鸿蒙AI智能手表HUAWEI WATCH 5发布,重绘智慧未来新图景
- WordPress插件No category base移除分类目录category
- 40万m³/d!看上海城投水务泰和污水处理厂的领跑者标杆实践
- dedecms织梦5.7仿站视频教程(初级上部)
- JavaScript实现页面跳转方法大全
- CSS通用/元素/ID/类/子/伪元素选择器
- 泰达股份拟出售扬州万运100%股权聚焦生态环保主业
- DedeCMS Error Warning提示解决方法
- JavaScript语法构成/关键字保留字及变量
- 个人网站被恶意镜像解决方法
- CSS文本样式text
- 百度搜索引擎搜索查询的表现形式
- 新浪微博主页侧边栏跟随页面滚动代码
- wordpress网站文章链接自动提交给百度
- 帝国cms7.5登录密码忘记多次登录失败被锁解决办法
- wordpress主题导航菜单添加小图标
- WordPress二次元博客lolimeow主题v8.0下载
- WordPress音乐主题Always1.8使用教程
- wordpress博客网站QQ/微博快速登录插件Foxlogin
- 小米新品米家毛球修剪器:超长续航,剃毛不误,仅售49.9元,实用又经济
- 搜索
-
- 友情链接
-