Hacked WordPress core to add No Follow links
I’ve been procrastinating on restoring one of my PR Zero blogs to it’s original PR4 because the thought of manually looking for each sponsored post and deleting it was just too daunting. Today, I finally bit the bullet and added “No Follow” tags to the links. I think this is much easier and faster than finding and deleting each paid post.
I edited the post-template.php file in the wp-includes folder
// Andrew 3/28/2008 4:11PM (new function)
function wp_rel_nofollow_tag( $text ) {
global $wpdb;
$text = str_replace(”<a “,”<a rel=’nofollow’”,$text);
return $text;
}
function the_content($more_link_text = ‘(more…)’, $stripteaser = 0, $more_file = ”) {
$content = get_the_content($more_link_text, $stripteaser, $more_file);
$content = apply_filters(’the_content’, $content);
// Andrew 3/28/2008 4:11PM – this is the one line I added
$content=wp_rel_nofollow_tag($content);
$content = str_replace(’]]>’, ‘]]>’, $content);
echo $content;
}
Red indicates new code added.
Tested it out by using my FireFox SEO plugin. It highlights links with no follow in a different color.
Yep, pink highlights shows that it works. Even my internal links are with No Follow (have to fix that later
)
Disadvantage
- If there is a WordPress update, my changes will be wiped out. I have to manually put it again after the upgrade. (Yeah WP 2.5 is coming out any day now)
- My “Sponsored” categories still show do-follow links. I do not know exactly where to change this. So as a quick stop gap measure, I completely hide all excerpts of Sponsored category posts.
- If a post already has prior “no follow” tag inserted when the post was first written, the PHP code will add a duplicate “no follow” code into the link tag (eg: <a rel=”no follow” rel=”no follow” href=” …”> ). Can be fixed by modifying the code but I’m too lazy to even think of it. Still with the duplicate it is still valid as a no follow link.
After this I will submit to Google for reconsideration. However, if this doesn’t appease Google. I have no other choice but delete all the sponsored post manually
Popularity: 25% [?]




Leave a Reply