WordPress: How to remove the Website URL field from the comment form

WordPress logoAs a blogger, the URL field in the WordPress comments form is a constant pain – either spammers are using it to drop shady links, or readers feel compelled to fill it with garbage just to fill in the field. Either way, it’s a nuisance. But how do you get rid of it?

Well, I spent a long time searching for the solution to this problem last night, and I’ve written up a solution for removing the URL field that takes into account a number of different scenarios you might encounter!

Obligatory warning! Never apply these types of changes to a production site – I keep a copy of my website themes on a testing server and make changes there. I suggest you do the same! 

Before we begin

Most of the changes we’ll be making will be in your WordPress theme. In my experience, there are a few different scenarios that we need to be aware of:

1. Your WordPress theme doesn’t have a comments.php file

If your WordPress theme is missing the comments.php file, WordPress will use the default template, located in /wp-includes/theme-compat/comments.php. This is all well and fine, but the fix detailed below requires the comments.php file to exist in the theme directory.

To overcome this, copy the comments.php file from the folder above into your theme folder. Once you’ve done this, follow the next step:

2. Your WordPress theme has the comment fields inserted manually

Most modern themes will use the <?php comment_form(); ?> code snippet at the bottom of the comments.php file. If this isn’t present in your comments.php file, then you should look for a line of HTML/PHP code that refers to a ‘URL’ field. Simply delete that line and your WordPress comments form should now be missing the website field!

In this scenario, you don’t need to progress to the more advanced solution detailed below – you’re all done!

3. Your theme’s comments.php calls comment_form()

OK – so your comments.php file contains:

<?php comment_form(); ?>

And comments.php is located inside your theme directory? You’ve come to the right place! Step this way…

Remove the Website URL field

OK, open up your theme’s functions.php file and add the following code to the end of the file:

add_filter('comment_form_default_fields', 'url_filtered');
function url_filtered($fields)
  return $fields;

This code snippet is from TechHacking (link now dead). However, they talk about implementing it as a plugin. It’s easier if you just add the code to functions.php in your theme.

Now, refresh your blog pages and the URL field should be missing from the comment form. (Aside: if the changes don’t appear right away, make sure you’re not running a caching plugin, and if you are, be sure to flush the cache!)

26 thoughts on “WordPress: How to remove the Website URL field from the comment form

    1. Brecht

      I already figured it out: change the code to this:


      But you have to disable ‘require email’ in WP preferences

  1. Thanks, worked a treat! Just added the code above to my themes function.php file, hit save and job done. No more spammy links in the URL field. 🙂

  2. Steve

    This would not stop the vast majority of spam. Do you think the spambots fill in the fields? They just send POST requests the server and ignore the HTML. They know its WordPress and understand what is required to send the comment without needing to see the [input] tag for URL.

    You need to remove the part where WordPress processes the URL as well to make this truly effective.

    1. Adam Curry

      It will not technically stop the spam. But it can make it trivial to catch almost all spam.

      On my blog, 100% of my spam fills in the ‘URL field’.

      If I disable the URL field in comments.php, then I *know* with 100% certainty that any comment which fills in the URL field is spam. Why would a human send POST requests? 😛

      So I can set a simple rule that automatically deletes any comment that contains a URL in the URL field.

      1. That’s a great idea. How do you go about adding a rule based on the URL? Is there an option for this in Akesmet, or do you use some other plugin for spam filtering?

  3. MicroClerks

    I want to keep the URL field and just make it “fake” so the spammers post their url and it simply never shows up on the front end.

    Why? because the spammers comments are getting more legible each passing year and I want to collect them to make my blog look good. I’ll eventually delete them later on once I have traffic, but might as well abuse te abusers here.

  4. Jim

    I used option 3, but I had to insert:add_filter('comment_form_default_fields', 'url_filtered');function url_filtered($fields){  if(isset($fields['url']))   unset($fields['url']);  return $fields;}inside the existing php tags, rather than open/close another php tag

  5. David

    Very nice solution. I used the solution posted by Jim & that worked really well. Also I wanted to add that if you are using any comment_form() function to call the comments template & you have URL input textbox in it, then you would need to delete that input as well in order for the code to work correctly.

    Hope this helps someone.

  6. The comment field has physically been removed from the template AND we’ve used the function as mentioned above to remove it. Yet spam comments till appear with url’s submitted – welcome to the twilight zone (which is very annoying)!

  7. jared

    This is great. Thanks for the tip. It’s ironic that you didn’t do the same thing to this website, but I’m just happy to have it gone from my site.

  8. Mr.Yuck

    Works just fine on the Sparkling theme. I figure it will cut down on spam a little, even though Akismet does a fine job of blocking probably 99% of it. My blog has only been WordPress for about 4 months (was Blogger for a year before that), and I’ve gotten 4,000 spam comments in those 4 months.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s