WordPress无幸运金投网下载赛车投注插件外部链接自动添加nofollow标签
如果手动每个链接加入是很麻烦, 在wordpress写文章时,严格要求的话是需要在外部链接全部加上nofollow标签。在技术层面是有传递出去权重。有时内容会<金投网下载strong>幸运赛车投注引用或分享一些外部链接地址,这样所有的外部链接就会自动加上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 文件中,当然我们也可以通过代码实现无插件添加方法。
-
上一篇
-
下一篇
- 最近发表
- 随机阅读
-
- html5响应式时间轴页面模板大全
- 搜索引擎的工作原理(二)
- WHOIS域名信息查询php源码
- 苹果新款HomePod软件将助老款HomePod系列设备焕新春
- jquery自适应屏幕图片瀑布流布局代码
- 酷炫无比的无穷隧道3d特效
- 创意的分割线404错误页面代码
- php在线搜索音乐播放器源码
- dedecms织梦5.7仿站视频教程(初级上部)
- WordPress二次元博客lolimeow主题v8.0下载
- 帝国cms如何设置会员注册邮箱验证
- UNI Slumps 17% Following SEC Developments, BTC, ETH, DOGE, TON on the Rise (Market Watch)
- HTML5实现人工智能中国象棋网页小游戏
- 网站分类目录(图片)缩略图显示不正常问题
- 新浪微博主页侧边栏跟随页面滚动代码
- DV单域名免费试用ssl证书申请收费
- jquery css3图片翻转3D动画切换特效代码
- wordpress XIU主题(阿里百秀)小清新cms模板V5.6
- dedecms织梦仿站工具软件下载
- wordpess博客主题css/js链接版本号如何去掉
- 搜索
-
- 友情链接
-