Skip to content
Security

Remove the website field from the WordPress comment form

Remove the comment form's URL field with one filter, why it cuts some spam, and the settings that matter more for keeping comments clean.

By WP24×7 engineers5 min readPublished December 4, 2019Updated November 29, 2026

At a glance

A how-to for removing the Website field from the WordPress comment form with the comment_form_default_fields filter, which reduces link spam. It adds a second filter to discard URLs on save, lists the Discussion settings that matter more, explains when an anti-spam plugin is still needed and how to check the change worked.

Updated November 29, 2026 · For WordPress site owners with open comments

  • For WordPress site owners with open comments
  • Form change unset the url key in comment_form_default_fields
  • Server-side change clear comment_author_url in preprocess_comment
  • Better controls Settings, Discussion moderation rules
  • Not a cure bots still post text, so add layered protection
  • Where to put code a small plugin or child theme, after a backup

The Website field on a comment form is a gift to link spammers, who post a bland comment so their URL appears on your site. Remove the field with the `comment_form_default_fields` filter, and pair it with moderation settings.

Why does the field attract spam?

Many commenters leave it empty, but spam bots fill every field they find. When a comment is approved, the author's name links to that URL, which is what the spammer wants. Without the field, they have less reason to post, and you have fewer links to review. WordPress also marks author links with rel="ugc nofollow" by default, so they pass little search value, but bots do not know that and do not stop.

What is the code to remove it?

Add this to a site plugin or a child theme's functions.php, after a backup:

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

The url key is the Website field. The same array holds author (name), email and cookies (the "save my details" checkbox). Remove only what you want to lose. A form that asks for fewer things also tends to get more genuine comments.

Block themes use the Post Comments Form block, which calls comment_form() under the hood, so the same filter applies. Check the page afterwards, as a theme or plugin that replaces the comment form may skip it.

What about bots that skip the form?

The filter only changes the form shown to visitors. Comments submitted another way, such as through the REST API by a logged-in user, are unaffected. If you want to discard a URL from any submitted comment, filter it on save:

add_filter( 'preprocess_comment', function ( $commentdata ) {
	$commentdata['comment_author_url'] = '';
	return $commentdata;
} );

That also blocks bots that post straight to wp-comments-post.php with a URL in the request, which a form-only change would not stop. Keep both changes if spam is a real problem.

ChangeStopsDoes not stop
comment_form_default_fieldsThe field appearing to visitorsBots posting directly with a URL
preprocess_commentAny URL being saved with a commentLink spam written inside the comment text
Moderation settingsLinks and risky comments going liveSpam sitting in the queue
Filtering spam before it reaches the comment queue

Which settings help more?

Go to Settings, Discussion and review:

SettingEffectTrade-off
Comment author must fill out name and emailSlows casual botsFew
Users must be registered and logged in to commentRemoves most spamFewer comments
Automatically close comments on older postsOld posts attract much spamStops genuine comments on useful older articles
Comment must be manually approved, or author must have a previously approved commentNothing unseen goes liveMore moderation work
Hold a comment if it contains N or more links (set to 1 or 2)Catches link spamOccasional genuine link held
Comment Moderation and Disallowed Comment Keys listsHold or reject by word or addressNeeds upkeep

Do I still need an anti-spam plugin?

Often, yes, for any site with open comments. Akismet, made by Automattic, is the best-known option, and there are free alternatives that use a hidden field (a honeypot) or a challenge. Whichever you use, remember that plugins can fail silently when an API key expires or a service is down, so check the spam folder occasionally.

Some comment spam is also trackbacks and pingbacks. If you do not use them, turn off Allow link notifications from other blogs (pingbacks and trackbacks) in the Discussion settings.

What if I want no comments at all?

Many business sites do not need them. Turn comments off by default for new posts in Discussion settings, and use the Quick Edit bulk action to close them on existing posts. Some themes still show the "comments are closed" notice, and your theme or a plugin can hide it. An all-out disable removes the whole spam surface, including the comment feeds.

For example, a small blog gets a dozen comments a day, nearly all of them one-line praise with a link to an unrelated product site. The owner removes the Website field, holds any comment with one or more links for approval, and closes comments on posts older than a few months. Within a week the queue is mostly empty. The few genuine comments still arrive, and the owner still checks the spam folder once a week in case a real reader was caught.

What if I want to keep the field but reduce the abuse?

Keep it, and combine these steps: hold comments with links, require a previously approved comment, add a honeypot or an anti-spam service, and make author links nofollow (WordPress already adds ugc nofollow). The field then stays useful for genuine commenters who want to link to their own site.

How do I check that it worked?

  1. Look at the form

    Open a post in a private window.

  2. Submit a test comment

    Check it lands in moderation as expected.

  3. Clean old comments

    On the Comments screen, edit any approved comment that still links to a spam URL.

  4. Watch for a week

    Fewer link-stuffed comments in the spam folder is the signal.

Common mistakes

Overrun by spam bots?

An engineer can set up layered protection.

FAQ

Questions people ask

12 answers. Can't find yours? Ask an engineer.

Will removing the website field stop all comment spam?

No. It removes the incentive for link spam and cuts some of it, but bots still post text. Use moderation settings and an anti-spam service too.

Link to this answer
Does the filter hide the field in the comment editor?

It removes the field from the public form. Existing comments keep any URL they already have.

Link to this answer
My theme builds its own comment form. Will this work?

It works if the theme uses comment_form(), which is almost all of them. A page builder's custom comment widget may ignore the filter, so check the page.

Link to this answer
Does this work with block themes?

Yes, because the Post Comments Form block calls comment_form() under the hood. Check the page afterwards, since a theme or plugin that replaces the comment form may skip the filter.

Link to this answer
Why do spam bots want the website field?

When a comment is approved, the author's name links to the submitted URL, which is what the spammer wants. Bots fill every field they find, so removing it takes away the reward.

Link to this answer
Can bots still send a URL if the field is gone?

Yes, by posting straight to wp-comments-post.php. Clearing comment_author_url in the preprocess_comment filter discards it on save, so keep both changes if spam is a real problem.

Link to this answer
Which Discussion settings help most?

Hold comments with one or two links, require a previously approved comment, require name and email, close comments on old posts, and add words to the moderation and disallowed lists.

Link to this answer
Do I still need an anti-spam plugin?

Often, yes, on any site with open comments. Akismet is the best-known option and free alternatives use honeypots or challenges. Check the spam folder occasionally, because plugins can fail silently when a key expires.

Link to this answer
How do I turn comments off entirely?

Turn them off by default for new posts under Settings, Discussion, and use the Quick Edit bulk action to close comments on existing posts. This removes the whole spam surface, including comment feeds.

Link to this answer
Should I turn off pingbacks and trackbacks?

If you do not use them, yes. Untick the option that allows link notifications from other blogs in the Discussion settings, since some comment spam arrives as trackbacks.

Link to this answer
How do I check the change worked?

Open a post in a private window and look at the form, submit a test comment and check it lands in moderation, edit any approved comment that still links to a spam URL, then watch the spam folder for a week.

Link to this answer

Keep reading

Want an engineer on it?

Tell us what is wrong in plain words. A person reads it, today.