Removing the website field from the comment form in WordPress just needs a few lines of code in your functions.php of your Theme.

functions.php of your Theme
copy & paste
Advanced Comment Form > Remove website field

How it looks like

Compared Comment Form without Website Field

Comment Form with and without the website field.

How to remove the url field with code

For quick starters you can jump right to step 3. If the snippet doesn’t work, go back to square one.

1. Check your theme for a comments.php file

If there is no comments.php file in your theme’s folder, please check the solution below.

2. Check for the comment_form() function

If your theme does have a comments.php file, search for <?php comment_form(); ?> there. If not, you might find it in some other file. It might also be called using some arguments, but if you can’t find it at all, check the solution for missing comment_form() below.

3. Insert this code in your functions.php

If number 1 and 2 didn’t make any problems, simple insert the following lines into the functions.php file of your theme.

I recommend changing the “my_” prefic (as seen twice in the code snippet) to something that makes sense for your project or theme. e.g. wpcomments_remove_url_field_from_comment_form

4. Test

Potential issues / other solutions

Missing comments.php

If your comments.php file is missing and your theme doesn’t have some substitute, simply copy the file from /wp-includes/theme-compat/comments.php into your theme’s directory.

After doing so search the file (in your theme’s directory) for the input field for the website. In WP 3.9.1 it looks like this:

You can remove the whole code and should be done.

Missing call to comment_form();

If you can’t find a call to comment_form() in your theme files, you might check them for some manually coded comment form. Even when customizing comment forms a lot, developers need to send them to the correct url. So search your theme for a call to /wp-comments-post.php, like in the following line to find the form where the comment is send with.

<form action="<?php echo site_url( '/wp-comments-post.php' ); ?>"

If you did find the form, search for an input field for the url, similar to this one and remove all code that corresponds to it.

<input type="text" name="url" id="url" value="<?php echo esc_attr($comment_author_url); ?>" size="22" tabindex="3" />

hide the website field with CSS

If you are not able to hide the website field with the standard WordPress filter or the customizations from above, you might want to hide it. For the standard class of the website input field you can use this code:

This does technically still allow to enter and submit the url, but most commenters are probably not advanced enough to do so.

Coding insights

The filter used in the code example is defined in function  comment_form()  in the file  /wp-includes/comment-template.php

comment_form() was introduced in WordPress 3.0.0.

About The Author

Leave a Reply

Your email address will not be published. Required fields are marked *