How to Automatically No Follow All External Links in WordPress

Nofollow All External Link

What rel=”no follow” link  really means

How to Automatically No follow All External Links. Everywhere you see online there’s a link to click that leads you somewhere as a result of we’ve been trained by Google to believe that link is important to rank our sites in search results. But that’s only partially true. If you want to have good SEO and get that link juice from Google, you need to understand two things: no follow links and follow links (sometimes referred to as dofollow links).

Automatically no-follow all external links with a WordPress plugin. Alternately, to try this, paste the following code on your WordPress theme’s functions.php file.

The no-follow link may be an advanced SEO technique, wherever your journal doesn’t get an effect on by Google updates on link building.

Use No-follow Links in WordPress with Code

add_filter('the_content', 'auto_nofollow');

function auto_nofollow($content) {
//return stripslashes(wp_rel_nofollow($content));

return preg_replace_callback('/<a>]+/', 'auto_nofollow_callback', $content);

function auto_nofollow_callback($matches) {
$link = $matches[0];
$site_link = get_bloginfo('url');

if (strpos($link, 'rel') === false) {
$link = preg_replace("%(href=S(?!$site_link))%i", 'rel="nofollow" $1', $link);
} elseif (preg_match("%href=S(?!$site_link)%i", $link)) {
$link = preg_replace('/rel=S(?!nofollow)S*/i', 'rel="nofollow"', $link);
return $link;



Please enter your comment!
Please enter your name here