WP Mayor is supported by its audience. Our recommendations are based on our experts’ research and hands-on testing. If you purchase through a link on our website, we may earn a commission. Here’s why you can trust us.

How to Remove Website URL Field from the WordPress Comment Form

  Introduction
Spam comments are a huge problem for all blogs. In this article, we’ll see how to remove the website URL field from your WordPress comment forms using PHP code.
Our Top Picks

After reviewing and testing the best solutions, WP Mayor recommends:

WP Mayor is supported by its audience. Our recommendations are based on our experts’ research and hands-on testing. If you purchase through a link on our website, we may earn a commission. Here’s why you can trust us.
 Table of contents
Remove website URL from WordPress comment form

Over the course of my two years working on the WP Mayor blog, I’ve noticed that many commenters used the comments section to secure backlinks to their websites. We have been using spam detection plugins, but some human comments always sneak through. Ever since I have been mulling over ways to combat comment spam.

In a recent team meeting, Prithu, our new Editorial Manager, brought something to my attention:

WordPress automatically asks for commenters’ website URL in all submissions.

It was a lightbulb moment! We suddenly realized that there was a very simple solution to disable the comment URL for all comments.

In this article, I’ll talk you through why people submit spam comments. Next, I’ll guide you through the very simple process of removing the website URL field from the WordPress comment form.

Why do I keep getting SPAM comments?

Well, people submit spam comments to try and improve their SEO. They do this by adding their website URL. In this way, they’ll get a backlink from your site. They believe that the more backlinks from reputable sites they get, the better their SEO score.

This is a blackhat SEO trick and for the most part, it doesn’t work. However, every blog owner will tell you that they receive tens of spam comments every day nonetheless.

WordPress’s default comment form includes the following four fields: name, email, website URL, and the comment box.

To help prevent comment spam, we’ll be removing the website URL field listed above.

Deafult comment form
The default WordPress comment form

How to remove the website URL field from the WordPress comment form

In this solution, we’ll be using the following code snippet.

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

You can manually place this in your theme’s functions.php file or use a snippets plugin to be safer. Keep in mind that if you don’t know what you’re doing, you can easily change something in the functions.php file and harm your website.

In this case, I’ve used the Code Snippets plugin. Simply install and activate the plugin on your website, and add a new snippet.

Code Snippets

Type in a title and add the code. Activate the snippet and you’re good to go!

Add new snippet

To check out the final result, view the website in incognito mode on your web browser.

Remove website URL from comment form
The final result.

Combat comment spam on your WordPress website

Spam comments are a huge problem for all blogs. In this article, we’ve seen how to remove the website URL field from your WordPress comment forms using PHP code.

We hope this method has helped you combat comment spam and while we have you here, we recommend looking at a few other ways that may help. You can add reCAPTCHA, restrict comment submissions, and more.

If you’ve used this solution or come across another method, let us know in the comment section below. But hey – no spam comments! 😉

Gaby Abela
Gaby Abela
Gaby is the Project Operations Manager at WP Mayor. Architect by profession, designer by nature, she is dedicated to helping readers navigate the online world of WordPress. You can find her on Twitter @GabyAbela.
Get more expert advice like this delivered to your inbox every week.
Join thousands of designers, developers, and marketers who trust our experts to find and test the best tools and services for your website.
By signing up to our newsletter, you agree to receive electronic communications from WP Mayor that may include advertisements.
Get more expert advice like this delivered to your inbox every week.
Join thousands of designers, developers and marketers who trust our experts to find and test the best tools to build, improve, and optimize their websites.
By signing up to our newsletter, you agree to receive electronic communications from WP Mayor that may include advertisements.
Join the Conversation

One Response

  1. Thankyou, I hope this code remove url form premanently
    because i see someone still able to comment their url even we already remove it.

Leave a Reply

Your email address will not be published.

From web hosting to WooCommerce plugins and backup services, we have put together a collection of exclusive coupons and deals just for you.
WP Mayor_Icon_white

Reader Survey

Supercharge your WooCommerce store!