对于网站引用了太多的外部连接,权重会受影响,很多站长都比较在意这个细节,下面给出几种方案:

站外连接添加nofollow

function external_nofollow($content){
 preg_match_all('|href="(.*?)"|',$content,$matches);
 if($matches){
 foreach($matches[1] as $val){
 if( strpos($val,home_url())===false ) $content=str_replace("href="$val"", "href="$val" rel="external nofollow" ",$content);
 }
 }
 return $content;
}
add_filter('the_content','external_nofollow',999);

分类添加nofollow

function crunchify_nofollow_cat($text) {
global $post;
        if( in_category(1) ) { // YOUR CATEGORY ID HERE 可变
                $text = stripslashes(wp_rel_nofollow($text));
        }
        return $text;
}
add_filter('the_content', 'crunchify_nofollow_cat');

标签添加nofollow

function nofollow_cat_posts($text) {
global $post;
        if( has_tag(1) ) { // SET TAG ID HERE 可变
                $text = stripslashes(wp_rel_nofollow($text));
        }
        return $text;
}
add_filter('the_content', 'nofollow_cat_posts');

放functions.php里,效果就是给连接加上了rel="nofollow"。

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。