How to remove the website field from the post comment form – Learn WordPress from a to z

Tutorials 0 lượt xem

Comment spam is a big problem for many blogs. The biggest reason for spam comments is the desire to generate backlinks using the site’s website field in the WordPress comment form.

Since most spam is generated by automated bots, you can easily fight comment spam using free tools and plugins.

In order for the website not to be diluted by such spam, I will guide you to remove the website field from the comment form.

Why do people post SPAM comments?

The short answer to that question is SEO or search engine optimization. Let’s find out more details!

Have you ever received comments from users like “Best WordPress Theme”, “Make Money Online” or “MyBlog Name” on your website? Why do they use such keywords instead of their real names?

remove website field from post comment form

By default, the WordPress comment form has four fields: name, email, website URL, and comment box.

When displaying comments, WordPress automatically associates the commenter’s name with the website URL they provided.

This backlink provides an incentive for black hat SEO marketers and new bloggers. They believe that this practice can help them rank better for specific keywords in search engines.

This technique doesn’t work for SEO in most cases.

This is why I have completely removed the URL field from the WordPress comment form. In this way, I have significantly reduced the number of spam comments on the site.

Real users will leave comments on your articles whether they get backlinks or not. If someone doesn’t want to comment on your site because they don’t get a backlink, then you really have to question their intentions in the first place.

Here are specific instructions for removing the website field from the comment form.

Remove website field from WordPress comment form

Some users always want to learn how to do things manually instead of using a plugin. You can remove website field from comment form with the help of code.

To get started, you need to backup your entire WordPress site. This will help you restore your site files in case you mess anything up while editing the theme files.

Next, you need to copy and paste the following code into your theme or child theme’s functions.php file:

add_filter('comment_form_default_fields', 'unset_url_field');
function unset_url_field($fields){
    if(isset($fields['url']))
       unset($fields['url']);
       return $fields;
}
<div>
<span>1</span><span>2</span><span>3</span><span>4</span><span>5</span><span>6</span>
</div>

This code simply removes the website field from your WordPress comment form. You can visit the blog post on the website in an incognito tab to see it in action.

Epilogue

I hope this article helped you learn how to clear the URL field of a website.

If you find it interesting, you can follow the  WordPress basics section  to know more new knowledge.

Follow fanpage to receive the latest posts:  Group

Bài viết liên quan