Remove URL or Website Field on WordPress Comments

Want to remove the URL or website textbox field on your WordPress comment form? Or maybe just hide the website links they entered? This is usually done to discourage human spammers from commenting just to promote their (usually) unrelated sites.

Remove Comment Website Field Textbox

You have two options. One approach is to prevent visitors from inputting their links by removing the website field. The other approach is to allow visitors to add their website urls and just hide or prevent the links from being displayed on the front-end.

Remove Website / URL Field on Comment Form

Add this on your child-theme’s functions.php. This removes the comment urls completely. Website URL textbox will be removed and commenters won’t be able to add their website links, hence no urls are added to the database.

function ra_remove_comment_url_field( $field ) {
    return '';
}
add_filter( 'comment_form_field_url', 'ra_remove_comment_url_field' );

Hide Website or URL on the Comments Area

Note: The codes below also affect the Recent Comments Widget.

Add this on your child-theme’s functions.php. With this code, commenters will still be able to input their site addresses and you will be able to see the visitor urls on back-end (admin area) but the links won’t be displayed on the front-end. This might seem a little bit underhanded, but hey, it’s your blog and you have all rights and control over it.

function ra_hide_comment_url( $url ) {
    if ( !is_admin() )
        return '';
    else
        return $url;
}
add_filter( 'get_comment_author_url', 'ra_hide_comment_url' );

Hide Links on Comments Area but not on Pingbacks

Same procedure as above. This only hides the website url on Comments left by visitors but not on Pingbacks ( aka link to a post on another site). You should use this one if you want to keep a link back to those websites ( including your own ) that have linked to your page on their content. It just seems fair to allow links to another post that also linked to your own post. Be careful though as Pingbacks are heavily used in spamming. Some people just turn the functionality off for their blogs.

function ra_hide_comment_url( $url, $id, $comment ) {
    if ( !is_admin() && get_comment_type( $comment ) == 'comment' )
        return '';
    else
        return $url;
}
add_filter( 'get_comment_author_url', 'ra_hide_comment_url', 10, 3 );

Share This Post

2 Comments

Add a Comment
  1. Thanks for the awesome post. Accomplished exactly what I needed.

    – Chris

  2. I Googled “delete website option in comments” just for that reason and came up with this help. Perfect! Most appreciated.

Leave a Reply

Please write your comments in english. I delete anything that even remotely resembles spam.

Note: When posting code, enclose it in pre and code tags.
e.g. <pre><code> Add code here </code></pre>