Remove rel attribute added by Gutenberg WordPress

REMOVE REL ATTRIBUTE ADDED BY GUTENBERG, GUTENBERG automatically add rel attribute to the Anchor tag.

Please add the below code in your theme functions.php

//remove rel="noopener noreferrer" added in anchor tag
//below will remove from content and comments
//if rel is different just change rel in code
function remove_nofollow($string) {
	$string = str_ireplace(' rel="noopener noreferrer"', '', $string);
	return $string;
}
add_filter('the_content', 'remove_nofollow');
add_filter('comment_text', 'remove_nofollow');

Please let me know if it works for you. If any issue I will fix my code.

Leave a Comment

Your email address will not be published.