How to Automatically No follow All External Links in WordPress


According to Google for un trusted content and Paid links use rel=”nofollow” tag.This means that Google does not transfer Page Rank or anchor text to no follow external links.

Automatically no follow all external links with wordPress plugin .Alternately, to do this, paste the following code in your WordPress theme’s functions.php file.

No follow link is a advanced SEO technique, where your blog does not get affect by Google updates on link building.

Use No-follow Links in WordPress with Code

The following code helps to do not follow all external links in WordPress,add this code in WordPress theme’s functions.php file.

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;

Add No-Follow External Links With WordPress Plugin

If you, not a techie, then go for WordPress plugins to add rel= no follow for all external links in WordPress.Wp External links and External Links are 2 popular plugins available to do this job, use any one of them.

  1. Wp External links and
  2. External Links.