Remove link to comment authors website from wordpress Comments


Are you tired of moderating, removing or editing the URLs of people who post comments in your wordpress blog? Are you sick of all the comment spammers who post those cookie cutter comments using scripts in your blog just to post links in your blog via the comment links to comment authors site? Well I was! And that’s when I decided that I would hack the wordpress code a little bit to totally disable linking to commenter’s site from the comments posted in the blog.

The link to commenter’s site does serve some good purposes like letting the comment poster link to his/her blog/site which might have good resources and also allows free publicity and exchange of traffic between genuine blogs and sites via the comment links, but there is way too much nuisance and problems which weigh down these advantages.

Well this is what you need to do if you want to remove these links. Go to the wp-includes directory in your wordpress installation via ftp, locate a file called comment-template.php (in older versions of wordpress you would need to find comment-functions.php) , download the file, create a backup of the file to make sure you can upload a working copy in case you mess up.
Open the php file with notepad (any text editor) or any code editing software you may have. Now in the file at around line 106 you would locate a function called get_comment_author_link() (around line 347 if you are editing comment-functions.php) . The line number might vary from wordpress versions, but the code within the function is the same for all versions of wordpress after 1.5, so this hack will work for all versions of wordpress 1.5 and up. Within the function you would see the following lines
[sourcecode language=’php’] $url = get_comment_author_url();
$author = get_comment_author();
if ( empty( $url ) || ‘http://’ == $url )
$return = $author;
$return = “$author“;
return apply_filters(‘get_comment_author_link’, $return);

What this function does is, check if the comment author posted a URL when he/she posted a comment, if there is no url it just prints the author name, if there is an URL with the comment then wordpress prints the author’s name as a link to the author’s website. We are going to modify the function to just print the author’s name (without a link) even if a URL is present with the comment. For that just replace
[sourcecode language=’php’] $return = “$author“;
[/sourcecode] With
[sourcecode language=’php’] $return = $author;

And you are done! Just save the file, upload the file back into the server and you should get comments with links removed with just the author’s name throughout the website!

Next I am going to try to totally remove the URL field while posting comments into the blog to save the hassle of commenter’s entering a URL. Will get back with a quick guide for that when I succeed.


  • Thanks! The removing link from comment appears to only work wen the comment is linked to from a pings. Regular comment with an http:// is ignored. I’m running with WordPress 2.6.3.

  • Thanks for this tip. This will be very helpful to blogs whose most of the comments are spam. But some blogs I have do have sensible commenter but they are so naive regarding putting their URL. Most of them don’t have their own blogs or websites so they tend to put or as their URL. What I need is making the URL field optional. Anyway come to think of it, removing the URL option like you gave is better. Thanks again!

  • I know you wrote this going on two years ago, but it really helped me clean up all of my sites, so I wanted to say thanks … so thanks!

    @Burnedbrass: I just changed the function [get_comment_author_link] to: “return get_comment_author( $comment_ID );” so that the author’s name will always be used for the link no matter what, if anything, was entered into the website field of the comments form.

  • thanks for the info. I was havng the same problem and as i got over 289 coments in 8 hours and this happened for the first time in my site and the coments were so good that I felt like approvng it. Only later i found out that those were all spams and they were postng comments in order to increase their backlinks . Atlast i found out your blog and now removed site links, keep up the good work… \m/