Remove Comment Form Website Section

Posted by The Doctor on Jan 17, 2012 | Subscribe | Short Link
in Functions, Tips
as , , ,

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:

To see the tip click here.To hide the tip click here.
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.

Leave a Reply

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

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>