对于网站引用了太多的外部连接,权重会受影响,很多站长都比较在意这个细节,下面给出几种方案:
站外连接添加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"。
相关阅读:
本文《WordPress链接优化:给外链、分类和标签加上external nofollow》由网友投稿或:「admin」整理自网络。
转载请声明来自:云猴子 - https://www.yunhouzi.com/454.html
1,本站所有资源均来源于用户上传或整理与网络,如有侵权请【内容投诉】删除,我们将及时处理!
2,本站资源仅供大家学习和交流,请不要用于商业用途,下载后请于24小时后删除!
3,如果你也有好的资源,可以投稿到本站,有金币奖励和额外的收入!
4,从您进入本站开始,已表示您已同意接受本站【版权声明】中的一切条款!
6,申明:本站资源出售只是赞助,仅用于本站服务器和日常运营所需!不提供任何技术支持。
7,如压缩包提示有密码,www.yunhouzi.com
云猴子 » WordPress链接优化:给外链、分类和标签加上external nofollow