WordPress无赏金女王app官网下载苹果手机插件外部链接自动添加nofollow标签PC加拿大飞飞在线预测
在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 文件中,
- 最近发表
- 随机阅读
-
- CSS文本样式text
- JavaScript语法构成/关键字保留字及变量
- web前端position定位层:absolute+relative应用
- WordPress后台外观主题编辑器屏蔽&隐藏
- wordrpess文章链接如何301重定向
- 个人网站文章撰写建议及规范
- 通过PhpMyAdmin找回wordpress登录密码
- wordpress网站改版更换域名注意事项
- (dedecms)mysql数据库表前缀批量替换修改
- 织梦dede:arclist标签使用说明
- css样式float浮动后,父元素塌陷解决方法
- CSS3过渡效果transition
- PHPnow安装服务[apache
- HTML5表单元input(二)
- php在线搜索音乐播放器源码
- wordpress时光轴自适应主题jinsomB模板
- 个人网站dedecms设置URL绝对路径/地址
- wordpess博客主题css/js链接版本号如何去掉
- wordpress博客纯代码去掉分类目录Category
- wordpress个人网站如何搬到电脑本地修改
- 搜索
-
- 友情链接
-