Remove Links On Comments

Simple code to add to your themes functions.php file that will strip the link from the comment author name, remove website field from the comment form and strip out any clickable hyperlinks from comments.

//remove links from comments and remove website field from comment form
remove_filter('comment_text', 'make_clickable', 9);
function remove_html($comment) {
   return strip_tags($comment, '<strong><b><em><p>');
}
add_filter('get_comment_text', 'remove_html');
add_filter('comment_form_default_fields', 'unset_url_field');
function unset_url_field($fields){
    if(isset($fields['url']))
       unset($fields['url']);
       return $fields;
}
function wpt_no_comment_author_url( $url, $id, $commentr ) { 
	return ""; 
}
add_filter( 'get_comment_author_url', 'wpt_no_comment_author_url', 10, 3);

Alternate code for removing website field from comment form for some genesis themes:

//remove website field from genesis comment form
add_filter( 'genesis_comment_form_args', 'url_filtered' );
add_filter( 'comment_form_default_fields', 'url_filtered' );
function url_filtered( $fields ) {
 
if ( isset( $fields['url'] ) )
unset( $fields['url'] );
 
if ( isset( $fields['fields']['url'] ) )
unset( $fields['fields']['url'] );
 
return $fields;
}

Leave a Comment