How to remove the url field from the comment form

If you have ever run a blog, you must have faced the problem of comment spam. Spammers engage in comment spam for link building purpose.

One simple way to discourage spammers is to remove the url field from the comment form. This will ensure that spammers cannot use your comment form for link building purpose.

In this post I will share a small snippet which will remove the url field from your comment form.

I recommend you to use the code snippet plugin in order to run this piece of code. Using the code snippet plugin ensures that your changes remain intact even after you change your theme.

Snippet

function spice_remove_comment_website_url($fields) {
  unset($fields['url']);
  return $fields;
}
add_filter('comment_form_default_fields','spice_remove_comment_website_url');

 

Explanation.

The code is self explanatory. All we are doing is filtering the comment form output and removing the url field associated with it.

This is how the modified comment form will appear in the Twenty Twelve Theme.

Snippet for Genesis Theme framework

If you are using genesis framework then the above snippet will not work. The reason is that Genesis Framework handles the comment form output differently. So instead of hooking into core wordpress filter, we will hook into the filter provided by the framework.

Modified Snippet. 

function spice_remove_comment_website_url($fields) {
 
		unset($fields['fields']['url']);
		return $fields;
}



add_filter('genesis_comment_form_args','spice_remove_comment_website_url');

 

We use this snippet on this very blog.

The main difference here is that we are hooking to the filter provided by the Genesis Theme framework. Another difference is the way we are handling the $field array.

Using Plugins.

In case you are not comfortable with the code then you can use a plugin to remove the website url field. Here are a couple of them , Remove comment url Box and Disable hide comment url 

Thats it. As you can see it is quite simple to remove website field from your comment form. Do let us know if you have any questions.

Did you enjoy this article?
Get Awesome with WordPress. Subscribe and get awesome stuff delivered straight to your inbox.
I agree to have my personal information transfered to Mad Mimi ( more information )

Leave a Comment