Skip to main content
WordPress made easy with the drag & drop Total WordPress Theme!Learn More

Remove the Website Field from the WordPress Comment Form

Last modified: November 28, 2023

By default the WordPress comment form includes a website field so that the commenter can enter their URL. This article will show you why and how to remove it.

Why Remove the Website Field?

The main reason to remove the comment field is to prevent SPAM and to stop sharing your crucial “link juice” with random websites (aka SEO reasons). Whenever you link to another site, Google and other search engines can see this and they will assume that in some way you are in some way connected to or promoting that site. It is horrible for SEO to link to SPAM, malicious or simply irrelevant content.

It’s important to note that by removing the website field you may not necessarily stop Bots from spamming your site. Bots will usually try to submit comments anywhere without checking if the website field exists or not and simply dump spam and links inside the comment content. However, you can stop manual SPAMMERS, in other words, people that are manually going around and leaving comments on websites trying to get backlinks.

Obviously not every comment on your site will be a SPAM comment. You will likely also get real comments by real people who will enter their website URL into the field since it’s available. And even if these commenters don’t have malicious intent, linking to their website may not be ideal for your own SEO efforts (yes, WordPress adds a nofollow to the commenters website link, but it’s best to just not link at all).

How to Remove the URL Field with Code?

Below is a simple snippet you can add to your website (see our guide on “How to add Custom Code to your WordPress Site” if you aren’t sure how to do so). There is nothing to edit, just copy and paste the code and the site field will be removed from the comments form.

/**
 * Remove the website url field from the WP comment form.
 *
 * @link https://www.wpexplorer.com/remove-wordpress-comment-url-field/
 */
add_filter( 'comment_form_default_fields', function( $fields ) {
    unset( $fields['url'] );
    return $fields;
} );

How to Remove the Comment Link in the Frontend?

The code above will simply remove the url field from the WordPress comment form, but if your site already has a bunch of comments the old links will still show up on the front-end. In this case you’ll probably want to remove those as well.

Or perhaps you don’t want to remove the website field from the comment form. Maybe you still want to be able to look in the WordPress dashboard and see commenter urls or you will consider re-adding it in the future so you still want to collect the data. In that case rather then removing the field completely you can use the following code instead to simply remove the link from the front-end.

/**
 * Remove the comment author url from WordPress comments (keep for the post author and admins).
 *
 * @link https://www.wpexplorer.com/remove-wordpress-comment-url-field/
 */
add_filter( 'get_comment_author_url', function( $url, $comment_ID, $comment ) {
    if ( ! is_admin()
        && $comment->user_id !== get_post()->post_author
        && ! user_can( $comment->user_id, 'manage_options' )
    ) {
        return '';
    }
    return $url;
}, 10, 3 );

Why Doesn’t the Code Work?

If the code isn’t working, the most likely reason is because your WordPress theme is not using the native comment form and/or native front-end comment output. If this is the case, honestly, I would recommend switching to a better coded theme such as our Total theme. But if you don’t or can’t switch themes then you will need to contact the theme author and ask them how to accomplish the same thing with their custom code.

And if by any chance the snippets are outdated, please let me know in the comments. Also let me know in the comment why are you specifically removing the url field from your site?

Comments

No comments yet. Why don't you kick off the discussion?

Leave a Reply

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

Learn how your comment data is processed by viewing our privacy policy here.