WordPress无幸运金投网下载赛车投注插件外部链接自动添加nofollow标签
当然目前一些wordpress主题设置有这个nofollow标签功能。有些外部链接是没有加Nofollow标签,如果手动每个链接加入是很麻烦,当然我们也可以通过代码实现无插件添加方法。有时内容会<金投网下载strong>幸运赛车投注引用或分享一些外部链接地址,严格要求的话是需要在外部链接全部加上nofollow标签。在技术层面是有传递出去权重。
这样所有的外幸运赛金投网下载车投注部链接就会自动加上nofollow标签。可以直接找一些wordpress插件安装。在wordpress写文章时,
//文章自动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表单元form(一)
- 小米米家无线直发梳新色上市:云瑾紫,三挡调温,售价亲民,实用之选
- web前端CSS传统布局position属性
- 个人网站dedecms设置URL绝对路径/地址
- 个人网站本地搭建Apache+PHP+MySQL环境
- wordpress评论者链接在新窗口打开
- 个人网站dedecms设置URL绝对路径/地址
- 宝塔面板MySQL数据库自动重启设置
- 个人博客html5雪花飘落代码JS特效下载
- 织梦dede:arclist标签使用说明
- 网站域名要不要申请使用SSL证书(https)
- jQuery弹出层页面社交分享代码
- JavaScript实现页面跳转方法大全
- B站视频下载软件工具推荐
- 搜索引擎网址提交入口有哪些
- 搜索引擎的工作原理(三)
- 鼠标控制图片左右无缝滚动js特效
- CSS颜色color与度量单位em
- 个人网站dedecms设置URL绝对路径/地址
- 个人网站香港主机野草云选购
- 搜索
-
- 友情链接
-