什么是nofollow?

nofollow是HTML页面中a标签的属性值。它的用处是告诉搜索引擎\\\\”不要追踪此网页上的链接\\\\”或\\\\”不要追踪此特定链接\\\\”,也就是不会导出权重到此链接。

对于wordoress seo优化有着一定重要性。所以在文章内如果有外链地址,链接地址添加nofollw是很有必要的,

添加案例

添加rel=\\\\”nofollow\\\\”不导出自身网站权重

<a href=\\\\\\\"https://www.zhankr.net/\\\\\\\" 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\\\\\\\" /\\\\\\\',$content,$matches);
	if($matches){
		foreach($matches[1] as $val){
			if( strpos($val,home_url())===false ) $content=str_replace(\\\\\\\"href=\\\\\\\\\\\\\\\"$val\\\\\\\\\\\\\\\"\\\\\\\", \\\\\\\"href=\\\\\\\\\\\\\\\"$val\\\\\\\\\\\\\\\" rel=\\\\\\\\\\\\\\\"nofollow\\\\\\\\\\\\\\\" \\\\\\\",$content);
		}
	}
	return $content;
}

 

 

本站声明:
1. 本站所有资源来源于网络,分享目的仅供大家学习和交流! 2. 不得使用于非法商业用途,不得违反国家法律。否则后果自负! 3. 本站提供的资源,都不包含技术服务请大家谅解! 4. 如有链接无法下载、失效或广告,请联系站长处理!

再次声明:如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。