您现在的位置是:WordPress无ag电游游戏网址插件外部链接自动添加nofollow标签大满贯 >>正文
WordPress无ag电游游戏网址插件外部链接自动添加nofollow标签大满贯
暗中摸索网9477人已围观
简介//文章自动nofollowadd_filter( 'the_content', 'tin_seo_wl');function tin_seo_wl( $con...
//文章自动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标签。
可以直接找一些wordpress插件安装。有时内容会在wordpress写文章时,如果手动每个链接加入是很麻烦,当然我们也可以通过代码实现无插件添加方法。在技术层面是有
Tags:
相关文章
wordpress搭建网站不足之处/缺点
WordPress无ag电游游戏网址插件外部链接自动添加nofollow标签大满贯现在网络上很多个人网站大多数用wordpress、dedecms、帝国cms、emlog等开源程序搭建。WordPress是一款基于PHP语言开发的博客平台,国外开发开源程序,有很良好的扩展性。傻瓜式...
阅读更多
JavaScript简单返回顶部代码实例
WordPress无ag电游游戏网址插件外部链接自动添加nofollow标签大满贯更多返回顶部jquery特效代码、返回顶部js特效代码、返回顶部网页代码,js常用返回网页顶部方法,js返回顶部实例、JS简单返回顶部代码实现欢迎分享。实现网站底部返回顶部的方法有很多种,最简单就是使...
阅读更多
BTC Maintains $70K Despite Heightened GBTC Outflows, WIF Plummets Again (Market Watch)
WordPress无ag电游游戏网址插件外部链接自动添加nofollow标签大满贯Bitcoin’s price slipped to and under $70,000 yesterday, but the asset has reclaimed that level...
阅读更多