- This topic has 7 replies, 2 voices, and was last updated 3 years, 9 months ago by David.
-
AuthorPosts
-
June 23, 2020 at 4:55 am #1338530Alicia
Hi!
I’d love to remove placeholder text from Comment form. I’ve got the labels visible but can’t seem to remove the placeholder text.
I even followed this solution and tweaked it to see if I could get it to work. But, no dice.
June 23, 2020 at 7:04 am #1338713DavidStaffCustomer SupportHi there,
can you share the code you used to remove the placeholders ?
June 23, 2020 at 4:28 pm #1339510AliciaHi!
I went back and futzed with the code a bit and got the placeholders for Author and Email to disappear. Now, I’m needing the Website URL placeholder to disappear. I’m not sure if the filter I’m using is accurate even for Author and Email, since the solution was for a specific scenario.
Here’s my code:
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 id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30" />'; $fields['email'] = '<label for="email" class="screen-reader-text">' . esc_html__( 'Email', 'generatepress' ) . '</label><input id="email" name="email" type="email" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30" />'; return $fields; }
June 24, 2020 at 2:26 am #1339872DavidStaffCustomer SupportYou can include this in your function:
unset( $fields['url'] );
Add it before the
return $fields;
June 26, 2020 at 6:36 pm #1343208AliciaHi David,
I actually want to keep the Website field, I just want to get rid of the placeholder text. The code I grabbed doesn’t have the website field included, so I’m not sure of the proper syntax.June 27, 2020 at 1:26 am #1343360DavidStaffCustomer SupportOops sorry … try this:
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 id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30" />'; $fields['email'] = '<label for="email" class="screen-reader-text">' . esc_html__( 'Email', 'generatepress' ) . '</label><input id="email" name="email" type="email" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30" />'; $fields['url'] = '<label for="url" class="screen-reader-text">' . esc_html__( 'URL', 'generatepress' ) . '</label><input id="url" name="url" type="url" value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" />'; return $fields; }
June 30, 2020 at 4:20 pm #1347562AliciaHi David!!
Awesome sauce. That’s just what I needed!
Thanks!
July 1, 2020 at 2:25 am #1347892DavidStaffCustomer SupportGlad to be of help
-
AuthorPosts
- You must be logged in to reply to this topic.