admin管理员组文章数量:1122832
I'm using Classic Editor (not Gutenberg) and WP is adding rel="noopener noreferrer" to ALL the links, whether it is target="" or target="_blank" or target="_self"!
I want to remove noreferrer from my affiliate links - please help! Thank you!
I'm using Classic Editor (not Gutenberg) and WP is adding rel="noopener noreferrer" to ALL the links, whether it is target="" or target="_blank" or target="_self"!
I want to remove noreferrer from my affiliate links - please help! Thank you!
Share Improve this question asked Jun 1, 2019 at 11:14 NickNick 11 bronze badge1 Answer
Reset to default 0So WordPress provides a way to adjust these programmatically, but it's done at the time of post save, not post render, so the changes will only apply once you add the code snippet to your site, and the go and re-save your post(s).
And, it's only available from WP 5.1+
Here's the code snippet (add it to your themes functions.php
if you don't have any other way already)
add_filter( 'wp_targeted_link_rel', function ( $sRels ) {
$aRels = preg_split( '#\s+#', $sRels );
if ( is_array( $aRels ) ) {
$nKey = array_search( 'noreferrer', array_map( 'strtolower', $sRels ) );
if ( is_numeric( $nKey ) ) {
unset( $aRels[ $nKey ] );
}
$sRels = implode( ' ', $aRels );
}
return $sRels;
}, 10000 );
Again, once this is added to your site, then you'll need to manually go in and re-save your post(s) and this should update your links by removing noreferrer
.
本文标签: permalinksWP adding noopener and noreferrer to all links
版权声明:本文标题:permalinks - WP adding noopener and noreferrer to all links 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736288392a1928084.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论