移除WordPress自动添加noopener noreferrer属性

主机教程评论339字数 198阅读0分39秒阅读模式

最近博主发现wordpress给所有的外链都添加了“noopener noreferrer”属性,“noopener noreferrer”的意思是指链接“不要打开”、“不要追踪”让搜索引擎不要计入权重,所以说这个属性对我们网站影响还是挺大的。今天博主为大家带来了如何去掉这个属性的教程。

一、添加禁止自动添加代码

//WordPress 移除链接中的 rel="noopener" 属性
add_filter('tiny_mce_before_init','tinymce_allow_unsafe_link_target');
function tinymce_allow_unsafe_link_target( $mceInit ) {
	$mceInit['allow_unsafe_link_target']=true;
	return $mceInit;
}

二、执行数据库清除操作

在数据在运行下方代码即可删除已经添加的属性。运行前请自行备份数据库,不排除存在风险。文章源自国外主机测评-https://www.zjcp.org/14550.html

UPDATE wp_posts SET post_content = REPLACE( post_content, 'noopener noreferrer', '' )
文章源自国外主机测评-https://www.zjcp.org/14550.html文章源自国外主机测评-https://www.zjcp.org/14550.html
 
  • 本文由 主机测评 发表于2021年9月18日 00:00:00
  • 转载请务必保留本文链接:https://www.zjcp.org/14550.html

发表评论