Instead of targeting comments or posts separately, hook into the final HTML output and strip every rel="nofollow"
before it reaches the browser.
Add this to your functions.php (or better: a small custom plugin):
// Remove all nofollow from final HTML output
function wp_remove_nofollow_from_output($buffer) {
// Remove nofollow, ugc, and combinations
$buffer = str_replace(
['', '', '', '', ''],
'',
$buffer
);
return $buffer;
}
// Start output buffering
function wp_start_remove_nofollow() {
ob_start('wp_remove_nofollow_from_output');
}
add_action('template_redirect', 'wp_start_remove_nofollow');
How This Works
ob_start
captures the entire HTML page just before it’s sent to the browser.- It strips out any
rel="nofollow"
(no matter where it came from). - Works for posts, pages, menus, comments, plugins, SEO tools – everything.
Steps
- Go to Appearance > Theme File Editor > functions.php
- Paste the above code at the bottom (before
?>
if exists). - Save.
- Clear all caches (WordPress cache, browser, Cloudflare if using).
- Reload your site →
nofollow
should be gone.