WordPress无pc28在哪玩插件外部链接自动添加nofollow标签手机网投大平台
这样所有的外部链接就会自动加上nofollow标签。当然我们也可以通过代码实现无插件添加方法。在技术层面是有传递出去权重。如果手动每个链接加入是很麻烦, 在wordpress写文章时,pc28在哪玩手机网投大平台当然目前一些wordpress主题设置有这个nofollow标签功能。严格要求的话是需要在外部链接全部加上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 文件中,
- 最近发表
- 随机阅读
-
- wordpress用户头像无法(自定义)本地上传修改
- wordpress博客内容代码/字符自动转义问题
- DedeCMS织梦从入门到精通建站(仿站)视频教程全集
- php7.4帝国CMS报错Deprecated: Function get
- wordpress XIU主题(阿里百秀)小清新cms模板V5.6
- HTML5表单元form(一)
- 去掉织梦cms底部的Powered by DedeCms
- PHP彩虹工具网源码 支持插件扩展
- jquery自适应屏幕图片瀑布流布局代码
- 首款鸿蒙AI智能手表HUAWEI WATCH 5发布,重绘智慧未来新图景
- dedecms织梦5.7仿站视频教程(中级上部)
- wordpress禁止加载图片属性srcset和sizes
- 11.6亿元!沂源县沂河沂源源头水保护区环境治理与产业开发EOD项目一期将招标
- wordpress个人博客主题Grace8.0模板分享
- 帝国cms7.5登录密码忘记多次登录失败被锁解决办法
- HTML5实现人工智能中国象棋网页小游戏
- dedecms仿站之index.htm(主页模板)标签介绍
- PHP二维码在线制作生成网站源码
- wordpress时光轴自适应主题jinsomB模板
- HTML5+three实现3D酷炫拼魔方游戏代码
- 搜索
-
- 友情链接
-