Recently I was looking for a solution to remove or hide the website URL field on my comment form. By default, WordPress is shipped with a comment form with a name, email address and website fields. This has been the standard since the creation of WordPress CMS.

Personally, I don’t mind typing my URL or website address when completing WordPress comment form. It isn’t a problem for me, as I do have a website.

There are some people who don’t have websites. They are just there to read your content and if they have something to ask or comment about, they do sometimes use the comments form to leave comments. While the website field isn’t required on most forms, it’s just another field to deal with for folks who just want to write something quick.

Also, the website field has become a tool or technique for spammers to comment on blogs online just to spread their products and services on other blogs. Most times, they leave useless comments unrelated to the content and insert their website URLs to promote their blogs. This isn’t right and shouldn’t be allowed.

I wanted to remove the URL field on all my forms. I was searching and came upon this site which has a cool script to remove the form for WordPress blogs.

If you need to do the same, continue below to learn how to.

There are many ways and other techniques to use to remove the website field. For new users who can’t edit their WordPress files directly can use a plugin to do the job.

Users who want to use plugins to remove or hide the comment URL field can use this plugin. 

Another way to remove or hide the URL is to add the below code snippet to your function.php file. This file can be accessed from your WordPress admin page –> Appearance –> Editor.

When you’re there, select the function.php file and insert the below code are just after the last line in the file.

Copy and paste the code below into the file and save.

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

 

When you’re done, restart your webserver for the changes to apply. If you’re using cache plugins, the changes will apply after the caches are expired and your pages refreshed.

This will also work if you edit your function.php file directly via SSH terminal and add the above code snippet to it. Restart your webserver and look at the comment form again. This time, the URL field should be gone.

The code above creates a function called remove_url with $fields as argument. Then using WordPress Hook Add_filter(), we pass the argument to WordPress default comment_form_default_fields function.

If there’s a better way to do this, please comment below and let our audience know.

Enjoy!

 

remove or hide wordpress comment url