WordPress无北京k1赏金赚钱app0赛车下载app插件外部链接自动添加nofollow标签
在wordpress写文章时,当然目前一些wordpress主题设置有这个nofollow标签功能。可以直接找一些wordpress插件安装。如果手动每个链接加入是很麻烦,严格要求的话是需<赏金赚钱appstrong>北京k10赛车下载app要在外部链接全部加上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 文件中,有些外部链接是没有加Nofollow标签,当然我们也可以通过代码实现无插件添加方法。
- 最近发表
- 随机阅读
-
- Helen响应式wordpress博客主题,个人博客网站模板/html模板
- html+js简洁的音乐播放器,总有一款适合你
- CSS颜色color与度量单位em
- 当贝X5S Plus 4K激光投影仪震撼登场:国补价3999元,真实画质触手可及
- 李炎恢老师HTML5第一季视频教程下载
- 个人网站阿里云IPC备案10天办理完成
- wordpress主题纯代码禁止复制文章内容的方法
- js实现mp3音乐播放器ui界面代码
- 个人网站被恶意镜像解决方法
- WordPress时光轴图片主题Scopic2.0
- DedeCMS个人网站常见漏洞有哪些
- 爱奇艺qsv/腾讯视频qlv/优酷视频kux格式转换MP4
- html5+css3制作音乐列表播放器源码
- wordpress禁用古腾堡区块内容编辑器方法
- wordpress博客头部wp
- WordPress音乐主题Always1.8使用教程
- wordpress移除后台外观下的编辑和仪表盘的模块
- These Crypto Assets Dumped the Most as the Total Market Cap Shed Over $200B (Weekend Watch)
- wordpress个人博客主题Grace8.0模板分享
- 创意的分割线404错误页面代码
- 搜索
-
- 友情链接
-