WordPress无pg麻将胡了一百一拉插件外部链接自动添加nofollow标签网上正规靠谱的ag平台
有时内容会引用或分享一些外部链接地址,当然我们也可以通过代码实现无插件添加方法。这样所有的外部链接就会自动加上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 文件中,当然目前一些wordpre网上正规靠谱的ag平台ss主题设pg麻将胡了一百一拉置有这个nofollow标签功能。如果手动每个链接加入是很麻烦,有些外部链接是没有加Nofollow标签,严格要求的话是需要在外部链接全部加上nofollow标签。
- 最近发表
- 随机阅读
-
- 易优eyoucms模板源码安装教程
- 帝国cms提示“非法来源”解决方法
- css中position属性定位:absolute与relative
- dedecms仿站之list
- wordpress小程序导航收录/小程序模板主题
- 小米米家扫拖机器人 M40 S 国补后立打7折:从高价到低价,实惠与实用并存
- dedecms实现tag标签伪静态方法
- SEO网站编辑文章如何伪原创
- CSS3变形效果transform
- jQuery实现全屏图片滑块焦点图动画
- dedecms上传图片302error错误解决方法
- wordpress隐藏文章部分内容需要注册登录后可见
- html5 3D旋转木马幻灯片播放代码素材
- 科沃斯T50 Pro扫拖机器人水箱版,3999元降至2235元,百亿补贴优惠不妥协
- 网页出现Uncaught SyntaxError: Unexpected token错误
- jQuery实现全屏图片滑块焦点图动画
- DedeCMS个人网站常见漏洞有哪些
- 个人博客html5雪花飘落代码JS特效下载
- 呆错免费开源图床系统源码
- 浏览器屏蔽广告插件广告终结者
- 搜索
-
- 友情链接
-