Remove Comment Form Website Section
in Functions, Tips
as add_filter, comment_form, how-to, WordPress
From time to time an interesting Five-Minute-FixTM comes along that sparks a great reason to add another WordPress Tips post. The idea for this tip started with this comment at BuyNowShop.com:
… how to remove the website section when leaving a reply/comment …
The solution may be obvious to some and can be readily derived from the information found on the WordPress codex page for the `comment_form` function, but if you are new to WordPress and/or not familiar with writing a function to use with `add_filter`, here is a very simple and working snippet to use in your theme:
function wpfa_remove_comment_website_section(){
$commenter = wp_get_current_commenter();
$req = get_option( 'require_name_email' );
$aria_req = ( $req ? " aria-required='true'" : '' );
$fields = array(
'author' => '<p class="comment-form-author">' . '<label for="author">' . __( 'Name' ) . '</label> ' . ( $req ? '<span class="required">*</span>' : '' ) .
'<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . ' /></p>',
'email' => '<p class="comment-form-email"><label for="email">' . __( 'Email' ) . '</label> ' . ( $req ? '<span class="required">*</span>' : '' ) .
'<input id="email" name="email" type="text" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ' /></p>',
'url' => '' /** removes website section */,
);
return $fields;
}
add_filter( 'comment_form_default_fields', 'wpfa_remove_comment_website_section' );
Ideally, this will be placed in the ‘functions.php’ file of your theme, but better yet this should be included in the Child-Theme you created of the theme you want to modify.



It’s a good thing you didn’t remove your website section. I enjoy reading and commenting but I also like leaving my link.