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 questionable 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 or 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 Commenter Website or URL on Comments

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' );

Remove Website links on Comments not Pingbacks & Trackbacks

Same procedure as above. This only hides the website url on comments and not on pingbacks and trackbacks. 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.

function ra_hide_comment_url( $url ) {
    if ( !is_admin() && get_comment_type() == 'comment' )
        return '';
    else
        return $url;
}
add_filter( 'get_comment_author_url', 'ra_hide_comment_url' );
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

Anything that resembles spam is deleted. Keyword names are also changed or deleted.

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

ronangelo © 2012 - 2016 Frontier Theme
css.php