Theme Author
Tom
(@edge22)
Hi there,
You shouldn’t need to overwrite comments.php
.
Instead, add this function:
add_filter( 'comment_form_default_fields', function( $fields ) {
$commenter = wp_get_current_commenter();
$fields['author'] = sprintf(
'<label for="author" class="screen-reader-text">%1$s</label><input placeholder="%1$s" id="author" name="author" type="text" value="%2$s" size="30" />',
esc_html__( 'Name', 'generatepress' ),
esc_attr( $commenter['comment_author'] )
);
$fields['email'] = sprintf(
'<label for="email" class="screen-reader-text">%1$s</label><input placeholder="%1$s" id="email" name="email" type="email" value="%2$s" size="30" />',
esc_html__( 'Email', 'generatepress' ),
esc_attr( $commenter['comment_author_email'] )
);
return $fields;
}, 20 );
(@smellpress)
4 years, 7 months ago
I have made the name and email fields optional in the WordPress settings, and would like to remove the asterisks from the fields because they give a misleading impression that the fields are required.
I have copied
comments.php
into my child theme and have successfully modified some aspects of it, but cannot manage to changeplaceholder="Name *"
andplaceholder="Email *"
, even when when wrappingcomment_form($args)
instr_replace()
! Attempting to replace the HTML with$fields['author'] = "myMarkupHere"
ceases to do anything, though I can use that for fictional fields – a possible workaround?