How to remove the website field from WordPress comment?

By Faruque Ahamed Mollick

WordPress users often notice spamming on WordPress site generated by the comment section. The comment section already has four fields. These are comment text, name, email and website fields.

This is a common fact for WordPress users to often find spam comment text. But sometimes we also see spammers spam using the website field of the comment form.

The name of the user who comments on your WordPress post become a hyperlink with the website link that the user provides. But sometimes it can be found they are not putting their real name.

On one of my blogs, when I had the website field enable, I found the name like “Best web hosting” and similar to these types of spammy name. All these were linked to the URL. TheĀ URL is the link, user provided in the website field in the time of writing the comment on the post.

Surely, commenting on your post with a promotional or spammy type name without using the real name is a black hat SEO technique.

Finally, I decide to remove the website field from the comment form. From that day I remove that field, I notice the decreasing of comment which implies the intention of commenting.

How can you remove the website field from the comment section of WordPress?

Removing the website field from WordPress comment section is quite easy. You just need to write a few lines of code to disable the website field from WordPress comments.

Below is the simple code that can do this task:



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

Just put the above code in your theme’s functions.php file or you can also create your own plugin where you have to put the same code.

In the code above, you can see that we have created a function and we have unset the ‘url’ field inside the function. Then return to the fields. After that, we have passedĀ the function to the comment_form_default_fields hook via filter hooks.

Now no more irritating for spam comment. Smile and best of luck. Thanks for reading this post.

Also, read:

 

Leave a Reply

Your email address will not be published. Required fields are marked *