Why remove the URL field?
A comment form usually asks for a name, an email and a website. The website box is called the URL field. A URL is a web address. Spammers fill it with links to their own pages. If you remove the box, you get less spam.
You can do this with a small piece of code. The code goes in a file called functions.php. This file belongs to your theme. A theme controls how your site looks.
Method 1: Add code
- Log in to your WordPress dashboard.
- Go to Appearance, then Theme File Editor. In some versions it is under Tools.
- On the right, click functions.php.
- Scroll to the very bottom of the file.
- Paste this code:
function remove_comment_url_field( $fields ) {
unset( $fields['url'] );
return $fields;
}
add_filter( 'comment_form_default_fields', 'remove_comment_url_field' );
This code takes the "url" box out of the list of comment fields.
- Click Update File.
- Open any post on your site and look at the comment form. The Website box should be gone.
If the editor is switched off, use File Manager in your hosting control panel. Open wp-content/themes, then your theme folder, and edit functions.php there.
Method 2: Use a plugin
A plugin is an add-on for WordPress. If you prefer no code, a code snippets plugin lets you paste the same code safely.
- Go to Plugins, then Add New Plugin.
- Search for a code snippets plugin.
- Click Install Now, then Activate.
- Add a new snippet, paste the code above, and save it as active.
Snippets stay in place even if you change your theme.
If your site breaks
- Open File Manager in your control panel.
- Edit
functions.phpand remove the code you added. - Save the file.
Quick recap
- The URL field invites spam links.
- Add a small filter to functions.php, or use a snippets plugin.
- Back up first, and use a child theme if possible.
- Check a post to see the field is gone.