Site logo

Archived topic

Remove noreferrer from external links

1 reply · Started by Vijaykumar on February 28, 2019

Viewing posts 1–2 of 2

Hi
With new Gutenberg and Wordpress update, there is a functionality to add "noreferrer" back again for ALL the external links.

but in most of the cases, we only need "noopener".

Is there any support/hook from GP to disable adding noreferrer to external links?

I got a function to do this. Will this cause any issues?

add_filter( 'wp_targeted_link_rel', 'my_targeted_link_rel_remove_noreferrer' );
function my_targeted_link_rel_remove_noreferrer( $rel_values ) {
return preg_replace( '/noreferrer\s*/i', '', $rel_values );
}

Also, when I try to edit functions.php I see a message not to edit it and edit the child theme instead. Can I know how to do that and which file to edit?

Hi there,

can't see the code being an issue.

This article covers how to add PHP:

https://docs.generatepress.com/article/adding-php/

In this case you would be better to use the Code Snippets plugin that is referenced in that article. Setting up a child theme for one function isn't worth it.

This archived topic is closed to new replies.