Skip to content

Instantly share code, notes, and snippets.

@MarinescuLucia
Last active April 12, 2023 07:32
Show Gist options
  • Save MarinescuLucia/a8216efd62aff3f592bebe9f96503839 to your computer and use it in GitHub Desktop.
Save MarinescuLucia/a8216efd62aff3f592bebe9f96503839 to your computer and use it in GitHub Desktop.
//Customize phrase below the comments section title
add_filter( 'comment_form_defaults', 'my_comment_form_defaults' );
function my_comment_form_defaults($defaults) {
$defaults['comment_notes_before'] = '<p class="comment-notes">'. __( 'Custom text', 'neve' ).'</p>';
return $defaults;
}
//Customize form fields Name, Email, Website and cookie consent phrase
add_filter('comment_form_default_fields','alter_comment_form_fields');
function alter_comment_form_fields($fields){
$fields['author'] = '<p class="comment-form-author">' . '<label for="author">' . __( 'Custom name', 'neve' ) . '<span class="required"> *</span>' . '</label> ' . '<input id="author" name="author" type="text" required="required" maxlength="245" autocomplete="name" size="30"' . ' /></p>';
$fields['email'] = '<p class="comment-form-email">' . '<label for="email">' . __( 'Custom email', 'neve' ) . '<span class="required"> *</span>' . '</label> ' . '<input id="email" name="email" type="text" required="required" maxlength="100" aria-describedby="email-notes" autocomplete="email" size="30"' . ' /></p>';
$fields['url'] = '<p class="comment-form-url">' . '<label for="url">' . __( 'Custom website url', 'neve' ) . '</label> ' . '<input id="url" name="url" type="text" size="30" maxlength="200" autocomplete="url" value="" ' . ' /></p>';
$fields['cookies'] = '<p class="comment-form-cookies-consent"><input id="wp-comment-cookies-consent" name="wp-comment-cookies-consent" type="checkbox" value="yes"' . $consent . ' />' . '<label for="wp-comment-cookies-consent">' .__( 'Custom cookie consent', 'neve' ) . '</label></p>';
return $fields;
}
//Customize form field Comment
add_filter('comment_form_field_comment', 'my_comment_form_field_comment');
function my_comment_form_field_comment($field) {
$field = '<p class="comment-form-comment">' . '<label for="comment">' . __( 'Custom comment', 'neve' ) . '</label> ' . '<textarea id="comment" name="comment" type="text" cols="45" rows="8" maxlength="65525" required="required" ' . ' /></textarea>';
return $field;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment