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'";
-
}
No Comments so far
Leave a comment
Leave a comment
Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>