Tag External Links as Nofollow without WordPress Plugin

Tag External Links as Nofollow without any WordPress Plugin: Here I am sharing a little but important tip for you. It will add rel=nofollow tag to all external links on your sites. External links points to other sites from your site. Adding nofollow tag is important for Search Engine Optimization. You can do this by using some WordPress plugin. But using too many plugins can affect your site’s loading time. So here I am telling you how to do this without any plugin. It’s pretty easy and simple to do. You don’t need coding skills for this.

Also Read: Create Custom Affiliate URLs on WordPress

First of all, for those who don’t know what is the meaning of rel=”nofollow” – No follow tag is a method for stopping Search Engines bots follow any particular links. If you are using many external links on your content and those links are dofollow, Search Engine bots will follow those links. And of course you don’t want that. So you can prevent Search Engine from following these links using nofollow tag. You can also use it for any specific link of your site if you don’t want Search Engine to follow and index them.

Tag External Links as Nofollow without Plugin

All you have to do is adding a code on your WordPress theme. On your Dashboard go to Appearance > Editor. Open your theme’s function file (functions.php) and add the following code. Save the file.

// Add Rel Nofollow To External Links
function wp_nofollow($content)
return preg_replace_callback('/<a[^>]+/', 'wp_nofollow_callback', $content);
function wp_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_filter('the_content', 'wp_nofollow');

Backup your functions.php file before editing it. Now you have tagged External Links as Nofollow without any WordPress plugin. Also check out other WordPress related posts Here. Don’t forget to Share this with your friends if you found this helpful and Subscribe to RSS feed for daily updates.

You May Also Like

About the Author: PT

Istiak Rayhan is the founder of ThangMedia.com, a blog that aims to make bloggers' journey easier. Istiak loves to help newbie bloggers to build a better blog.

Leave a Reply

Your email address will not be published. Required fields are marked *

Subscribe To Our Newsletter

Subscribe To Our Newsletter

Join our mailing list to receive the latest news and updates from our team.

You have Successfully Subscribed!