WordPress如何在文章的外链中添加nofollow

2021-08-13 0 857

什么是 nofollow?
nofollow 是标记的属性值。
nofollow 的作用是什么?
nofollow 是告诉搜索引擎不要在此页面上跟踪链接或不跟踪此链接,也不会导出此链接。
Nofollow 对WordPress 优化具有一定的重要性。如果文章中存在外部链条地址,则必须添加 nofollw。
nofollow 案例

1
<a href=”https://www.huizhanii.com/” rel=”nofollow” >汇站网</a>

使用方法

将以下代码添加到主题functions.php文件

//给文章外链添加 nofollow
add_filter('the_content','web589_the_content_nofollow',999);
function web589_the_content_nofollow($content){
preg_match_all('/href="(.*?)" rel="external nofollow"  rel="external nofollow" /',$content,$matches);
if($matches){
foreach($matches[1] as $val){
if( strpos($val,home_url())===false ) $content=str_replace("href="$val" rel="external nofollow"  rel="external nofollow" ", "href="$val" rel="external nofollow"  rel="external nofollow"  rel="nofollow" ",$content);
}
}
return $content;
}

 

转载请注明:汇站网 » WordPress 如何在文章的外链中添加 nofollow

收藏 (0)

微信支付 微信扫一扫

支付宝支付 支付宝扫一扫

点赞 (0)

站长资源下载中心-找源码上汇站

常见问题
  • 如果付款后没有弹出下载页面,多刷新几下,有问题联系客服!
查看详情
  • 本站所有资源版权均属于原作者所有,这里所提供资源均只能用于参考学习用,请勿直接商用。若由于商用引起版权纠纷,一切责任均由使用者承担。
查看详情

相关文章

联系官方客服

为您解决烦忧 - 24小时在线 专业服务