Wordpress Hack » Inserting rel nofollow on links in all categories…
I wanted to add rel='external nofollow' onto every Link in every Category that didn't have an explicit rel attribute defined. I looked though the Wordpress Codex but found no Plugin Hooks to do it so I broke out the source code.
Somewhere down the chain the link markup "<a ..." is generated in the function get_links() found in /wp-include/links.php (approx line 142). I added two lines of code shown below and it works a treat.
Before
PHP:
-
$rel = $row->link_rel;
-
-
if ($rel != '') {
-
$rel = " rel='$rel'";
-
}
After
PHP:
-
$rel = $row->link_rel;
-
-
if ($rel != '') {
-
$rel = " rel='$rel'";
-
} else {
-
$rel = " rel='external nofollow'";
-
}