Tweet about this on TwitterShare on FacebookShare on Google+Share on LinkedIn

WordpressI like messing with WordPress code or any other website software script’s code for that matter. Sometimes just for fun. Other times to change or modify the behavior of something. The thing about WordPress is it is pretty simple and difficult to really mess something up. Not that it isn’t possible to mess your website up, but much more difficult compared to some of the others I use.

 

Lately I have been on a dofollow / nofollow kick for some reason. I have been modifying and change various links from nofollow to dofollow, or vice versa. Oftentimes a link is repeated several times almost repetitively in some cases. I have been trying to decide whether some links need to appear on a page so much, and whether they really need to be followed.

So recently I started looking at an individual or single post with several comments and replies. Then, I started thinking about all the “Reply to this comment” links. Not only do they appear numerous times, but you will also see them when replying to a reply. So they can really add up.

The link structure looks something like this:

Google Pagerank Update August 4, 2011

Google Pagerank Update August 4, 2011

 

Normally I don’t care too much, but it is the ?replytocom=62#respond part that I don’t like too well. I doubt that this will have a very big influence or anything, but I just don’t like it so well.

I haven’t decided whether to commit to setting these to nofollow or leaving them at the standard dofollow.

I did briefly change them to nofollow just make sure that I could do so easy enough. All I did was modify a core WordPress php file, which took all of 2 minutes. The drawback to modifying a core file is next time there is a WordPress update or upgrade it will be overwritten and change back. So one would need to re-apply the change after an upgrade.

The file to edit is located here:
/wp-includes/comment-template.php

If you want to set these to nofollow you should first download and backup comment-template.php to your local pc. Just in case you mess up and/or want to change it back.

After you have downloaded a backup, open the file with a text editor and look for:

if ( get_option(‘comment_registration’) && !$user_ID )
$link = ‘<a rel=”nofollow” href=”‘ . esc_url( wp_login_url( get_permalink() ) ) . ‘”>’ . $login_text . ‘</a>’;
else
$link = “<a class=’comment-reply-link’ href='” . esc_url( add_query_arg( ‘replytocom’, $comment->comment_ID ) ) . “#” . $respond_id . “‘ onclick=’return addComment.moveForm(\”$add_below-$comment->comment_ID\”, \”$comment->comment_ID\”, \”$respond_id\”, \”$post->ID\”)’>$reply_text</a>”;
return apply_filters(‘comment_reply_link’, $before . $link . $after, $args, $comment, $post);
}

Change to:

if ( get_option(‘comment_registration’) && !$user_ID )
$link = ‘<a rel=”nofollow” href=”‘ . esc_url( wp_login_url( get_permalink() ) ) . ‘”>’ . $login_text . ‘</a>’;
else
$link = “<a rel=”nofollow” class=’comment-reply-link’ href='” . esc_url( add_query_arg( ‘replytocom’, $comment->comment_ID ) ) . “#” . $respond_id . “‘ onclick=’return addComment.moveForm(\”$add_below-$comment->comment_ID\”, \”$comment->comment_ID\”, \”$respond_id\”, \”$post->ID\”)’>$reply_text</a>”;
return apply_filters(‘comment_reply_link’, $before . $link . $after, $args, $comment, $post);
}

You are simply adding rel=”nofollow” and saving the changes back to your hosting account. If you use some form of caching plugin you may need to clear it, or wait for the next update / dump to happen for the changes to take effect.

Here is a screen shot using a Firefox plugin that highlights dofollow and nofollow links. Dofollow is purple/blue, and nofollow is pink/red.

 

Original Reply to this comment dofollow:
Wordpress Dofollow Reply

 

Edited Reply to this comment nofollow:
Wordpress Nofollow Reply

Of course modify and make changes to your files and website at your own risk!

About: Jeremy LeSarge - AKA: Ray (212 Posts)

I am the site owner and administrator of DialMe.com. I provide help and tips for Boonex Dolphin on the main part of this website where you will also find an assortment of other resources. Here, on the blog I write about a variety of topics surrounding WordPress, technology, social media/networking, SEO, and webmaster resources.