Removing URL Field from Comment Form

By default there is a URL input field in WordPress comment system. The input data of this field eventually links the commenter's name and appears as a live link as soon as the comment becomes approved. Such links sometime leads people to visit their site as well; perhaps that's one of the most important reason why many site owner tend not to like such functionality.

Today, in this post I will show you how to remove the "URL" input field from the default comment form. This is fairly easy and doesn't require to write any big function. So, here it is.

function remove_comment_url_input($fields) {
   if(isset($fields['url'])) { 
      unset($fields['url']); }
      return $fields; }

All you need to do is to copy the code and paste it on your theme's functions.php file and simply hit the update button.

Now, if you take a close look at the function you can see that at the end our function; it is being called to a very specific(comment_form_default_fields) add_filter action hook. It is directly associated with the comment_form function that generates the comment form itself on our browser. So, all we are doing here is, asking the comment_form function to unset the URL input field through add filter.

Best part is, you can remove author, email or URL field as it suggests on comment form function arguments through fields array.


Commenting is disabled.