0

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!

0

So 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.