How To Remove The URL Field From Default WordPress Comments

WordPress has a comments section built into it. It allows users to interact with each other and to comment on published articles. Some website owners do not like that WordPress comments requires the user to include a URL by default. Additionally, users may not realize that is is not a required field.

It is also not a common field on other comment plugins, such as Disqus. However, I personally find value in asking users for their URL if they have a website. However, I understand why some website owners might not like that.

This is not an issue with WordPress by any means but it is simply an aesthetic choice that some site owners would like to make. The good news here is that there are a number of ways that this can be removed. Some fixes are more involved, but others are as simple as pasting some code in your functions.php file (in a child theme) or a site-specific plugin.

1. Adding Code To Functions.php / Site-Specific Plugin (Preferred)

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

The above code is my preferred method of removing the URL field from the WordPress comments section. It can be pasted into your functions.php or a site-specific plugin. It simply works. You do not need to edit any of your files or install another plugin.

2. Adding A Plugin

You can also install this plugin from the WordPress.org directory. It will also remove the URL field from your comments section.

This is a simple option. However, I prefer to put very simple functions into my own little plugin or a functions.php file. This way the code is well documented and labeled that way it is easier to find later.

3. Editing The Comments.php file in your theme files (Not Recommended)

 ‘url’ =>
    ‘<p class=”comment-form-url”><label for=”url”>’ . __( ‘Website’, ‘hopefullysomethinghere’ ) . ‘</label>’ .
    ‘<input id=”url” name=”url” type=”text” value=”‘ . esc_attr( $commenter[‘comment_author_url’] ) .
    ‘” size=”30″ /></p>’,
);
The above code is in your comments.php file (or some similar variation). In this case, you need to remove this code. Keep in mind, only make these changes after copying the comments.php file into a child theme. This way it will be saved in the event of a theme update.

Closing Thoughts

It’s quite handy that WordPress has a URL field in the comments section. It was likely designed to allow bloggers to speak to other bloggers and has since just become kind of a gold standard in online comment forms. That being said some users simply don’t like asking for a URL or simply don’t want to help promote their commenters websites.

Either way, it can be done in a number of ways to accommodate users of varying levels of skill.

scott hartley

About the author

Scott is a web performance geek, lover of all things coffee, and avid video game player. His WordPress work delves into web performance, web security, and SEO.

1 thought on “How To Remove The URL Field From Default WordPress Comments”

Leave a Comment