WordPress无真人庄网投网平台闲游戏平台插件外部链接自动添加nofollow标签
有些外部链接是没有加Nofollow标签,当然我们也可以通过代码实现无插件添加方法。 在wordpress写文章时,当然目前一些wordpress主题设置有这个nofollow标签功能。可以直接找一<网投网平台strong>真人庄闲游戏平台些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 文件中,
- 最近发表
- 随机阅读
-
- javascript数据类型(typeof操作符)
- 小米米家扫拖机器人 M40 S 上市:升降导航、大吸力清洁新体验,2999元起,智能家居新选择!
- favicon.ico图片在线制作PHP源码
- WordPress无插件外部链接自动添加nofollow标签
- 搜索引擎的工作原理(四)
- JavaScript对象中的方法/如sort(参数)方法
- wordpress瀑布流图片主题PhotoBroad模板2.0
- SEO网站编辑文章如何伪原创
- 太空动态404错误页面html代码
- 仿新浪微博个人主页html网站模板
- 帝国cms如何设置会员注册邮箱验证
- wordpress网站登录出现500Internal Server Error
- QQ互联申请接入qq登录APPID与APPKey方法
- CSS3浏览器前缀和长度单位rem
- WordPress文章图片URL链接地址批量替换
- WordPress微博主题模板TleWeiboFor2.0
- 李炎恢老师HTML5第一季视频教程下载
- CSS3渐变效果linear
- 个人网站文章撰写建议及规范
- maolai博客模板wordpress主题免费下载
- 搜索
-
- 友情链接
-