您现在的位置是:WordPress无猜庄闲和是什么游戏插华体会·(hth)体育件外部链接自动添加nofollow标签 >>正文
WordPress无猜庄闲和是什么游戏插华体会·(hth)体育件外部链接自动添加nofollow标签
有则改之网4人已围观
简介//文章自动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 文件中,
在wordpress写文章时,
可以直接找一些wordpress插件安装。如果手动每个链接加入是很麻烦,Tags:
相关文章
WordPress时光轴图片主题Scopic2.0
WordPress无猜庄闲和是什么游戏插华体会·(hth)体育件外部链接自动添加nofollow标签Scopic主题已经过汉化,主题整体简洁大方,支持主流游览器,完美支持响应式,内置多种配色方案,内置多种文章样式,是一款功能强大的WordPress图片主题。Scopic主题特点:支持在线自定义,Wo...
阅读更多
wordpress简洁单栏个人博客模板
WordPress无猜庄闲和是什么游戏插华体会·(hth)体育件外部链接自动添加nofollow标签这是一款浅粉红色背景单栏的wordpress个人博客主题,非常个性简单、简洁的前端界面。模板背景颜色可根据自己的喜好修改,主页是一个单页的网页,文章页、栏目页可和主页设计一样,也可发挥你的灵感创意来设...
阅读更多
JavaScript对象中的方法/如sort(参数)方法
WordPress无猜庄闲和是什么游戏插华体会·(hth)体育件外部链接自动添加nofollow标签一、转换方法对象或数组都具有toLocaleString()、toString()和valueOf()方法。其中toString()和valueOf()无论重写了谁,都会返回相同的值。数组会讲每个值进...
阅读更多