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
$rel = $row->link_rel;
if ($rel != '') {
$rel = " rel='$rel'";
}
After
$rel = $row->link_rel;
if ($rel != '') {
$rel = " rel='$rel'";
} else {
$rel = " rel='external nofollow'";
}
About this entry
You’re currently reading “Wordpress Hack » Inserting rel nofollow on links in all categories…,” an entry on Weblog of Michael Cutler
- Published:
- 1st December 2005 / 1:12am
Related Entries
- Wordpress Hack » Reading MySQL username & password from wp-config.php
24th January 2006 - Blocking Wordpress comment spammers by User-Agent
15th November 2005 - Wordpress 2.0.3 ‘Bug Fix & Security Release’
1st June 2006 - Changes in Wordpress 1.5.2
15th August 2005 - More thoughts on SpamKit…
16th December 2005
No comments
Jump to comment form | comments rss [?] | trackback uri [?]