- This topic has 11 replies, 3 voices, and was last updated 5 years, 11 months ago by Tom.
-
AuthorPosts
-
May 24, 2018 at 11:59 pm #584184pancakebg
Hey guys, can you help me to change the text on the placeholders in the comments section?
I need to replace the name, e-mail and if possible to remove the website field.
Also i would like to know if i can change the text on this: Save my name, email, and website in this browser for the next time I comment.
I already found this posted by Tom but when i add it to the child theme function.php and replace the fields – nothing happens.
add_filter( 'comment_form_default_fields', 'tu_adjust_comment_form_fields' ); function tu_adjust_comment_form_fields( $fields ) { return array( 'author' => '<label for="author" class="screen-reader-text">' . esc_html__( 'Name', 'generatepress' ) . '</label><input placeholder="' . esc_attr__( 'Name', 'generatepress' ) . ' *" id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30" />', 'email' => '<label for="email" class="screen-reader-text">' . esc_html__( 'Email', 'generatepress' ) . '</label><input placeholder="' . esc_attr__( 'Email', 'generatepress' ) . ' *" id="email" name="email" type="email" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30" />', 'url' => '<label for="url" class="screen-reader-text">' . esc_html__( 'Website', 'generatepress' ) . '</label><input placeholder="' . esc_attr__( 'Website', 'generatepress' ) . '" id="url" name="url" type="url" value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" />', ); }
Thank you! π
May 25, 2018 at 9:27 am #584547TomLead DeveloperLead DeveloperHi there,
You can try something like this:
add_filter( 'comment_form_default_fields', 'tu_filter_comment_fields' ); 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="' . esc_attr__( 'Name', 'generatepress' ) . ' *" 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 placeholder="' . esc_attr__( 'Email', 'generatepress' ) . ' *" id="email" name="email" type="email" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30" />'; $consent = empty( $commenter['comment_author_email'] ) ? '' : ' checked="checked"'; $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">Your modified text here</label></p>'; unset( $fields['url'] ); return $fields; }
May 25, 2018 at 12:16 pm #584678pancakebgSadly, it does not work for me.
The placeholders did not changed.
The box with the URL still there.
However, the “Save my name, email, and website in this browser for the next time I comment.” did changed but the check box goes between the “Name” and “Email” boxes on the upper row.
That’s a bit hard to figure it out how to do it. ;[
May 25, 2018 at 1:33 pm #584709LeoStaffCustomer SupportIs the code still added?
I tested the same code using Code Snippets and everything worked for me.
May 25, 2018 at 2:09 pm #584725pancakebgI removed it but i will add it back so you can check it out.
Thanks! π
May 25, 2018 at 8:58 pm #584870TomLead DeveloperLead DeveloperCan you share the code with the changes you added to your site?
May 26, 2018 at 12:37 am #584940pancakebgYes, here is the code:
add_filter( 'comment_form_default_fields', 'tu_filter_comment_fields' ); 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="' . esc_attr__( 'NEW NAME HERE', 'generatepress' ) . ' *" 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 placeholder="' . esc_attr__( 'NEW EMAIL HERE', 'generatepress' ) . ' *" id="email" name="email" type="email" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30" />'; $consent = empty( $commenter['comment_author_email'] ) ? '' : ' checked="checked"'; $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">TEXT FOR CHECKBOX HERE</label></p>'; unset( $fields['url'] ); return $fields; }
May 26, 2018 at 9:16 am #585194TomLead DeveloperLead DeveloperAnd this is being added to your child theme?
Any other functions/changes made to template files regarding the comments area?
Maybe 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 placeholder="NEW NAME HERE *" 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 placeholder="NEW EMAIL HERE *" id="email" name="email" type="email" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30" />'; $consent = empty( $commenter['comment_author_email'] ) ? '' : ' checked="checked"'; $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">TEXT FOR CHECKBOX HERE</label></p>'; unset( $fields['url'] ); return $fields; }
May 26, 2018 at 10:55 am #585256pancakebgThanks Tom!
I have a bit of success with the last one but the check box still between the two fields
I have no problem to remove this box if you know how to do it.
For the fields i use this css:
@media (min-width: 769px) { .comment-form #author, .comment-form #email { width: 48%; float: left; } .comment-form #email { float: right; } .comment-form #url { width: 100%; } }
I also have few added filters in the function.php about the comments mainly to change the names.
The code is up and you can check the site.
Thank you!
May 26, 2018 at 9:21 pm #585434TomLead DeveloperLead DeveloperTry this CSS:
.comment-form-cookies-consent { clear: both; }
May 27, 2018 at 8:20 am #585695pancakebgWorks great, thank you!
May 27, 2018 at 9:22 am #585752TomLead DeveloperLead DeveloperNo problem! π
-
AuthorPosts
- You must be logged in to reply to this topic.