function theme_comment_fields($fields) {
$commenter = wp_get_current_commenter();
$req = get_option('require_name_email');
if( $req ) $reqd = '<span class="required">' . __('*',) . '</span>';
$fields['author'] = '<p class="comment-form-author"><label class="text" for="author">' . __( 'Name' ) . $reqd . '</label><input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30" /></p>';
$fields['email'] = '<p class="comment-form-email"><label class="text" for="email">' . __( 'Email' ) . $reqd . '</label><input id="email" name="email" type="text" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30" />' . '</p>';
$fields['url'] = '<p class="comment-form-url"><label class="text" for="url">' . __( 'Website') . '</label>' . '<input id="url" name="url" type="text" value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" /></p>';
return $fields;
}
add_filter('comment_form_default_fields','theme_comment_fields');
Thanks man, that’s awesome.
No problem. Just drop the new function in your theme’s functions.php file and it will kick in automatically.
(@mtpultz)
12 years, 2 months ago
How do you maintain the required and commenter information when you modify or add fields to the comment_form(). Example I wanted to alter the __(‘Name’) to be __(‘Your name’) with some added stuff under the form element but I won’t get the $req value now or esc_attr( $commenter[‘comment_author’] ). Anyone know how to get around this?