Archived topic
Comment form styling
1 reply · Started by Allen on January 13, 2022
hi
a) Is this the correct snippet for me to change comment's author name placeholder text? It's working for my side, just want to double check.
add_filter( 'comment_form_default_fields', 'tu_filter_comment_fields', 20 );
function tu_filter_comment_fields( $fields ) {
$commenter = wp_get_current_commenter();
$fields['author'] = '<label for="author" class="screen-reader-text">' . esc_html__( 'Name', 'generatepress' ) . '</label><input placeholder="NEW TEXT HERE" id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30" />';
return $fields;
}
b) how can i add text before comment's author name, I tried to put using CSS but its displaying on top instead on the left side.
Thank you!
Hi there,
that snippet changes the placeholder and it can change the label text.
In the snippet look for this:
esc_html__( 'Name', 'generatepress' )
Change the Name to whatever you want before the field.
And look for and remove this:
class="screen-reader-text"