- This topic has 18 replies, 5 voices, and was last updated 4 years, 10 months ago by
Leo.
-
AuthorPosts
-
April 5, 2018 at 11:27 am #542229April 5, 2018 at 10:10 pm #542614
Tom
Lead DeveloperLead DeveloperHi there,
Give this a shot:
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" />', ); }
Adjust the
placeholder
value.April 6, 2018 at 3:53 am #542799Paritosh Negi
Thank you Tom… it worked!
April 6, 2018 at 9:22 am #543082Tom
Lead DeveloperLead DeveloperYou’re welcome π
June 21, 2018 at 10:52 pm #605769Randy
Like this? (just one line to simplify):
‘author’ => ‘<label for=”author” class=”screen-reader-text”>’ . esc_html__( ‘Name’, ‘generatepress’ ) . ‘</label><input placeholder=”‘ . esc_attr__( ‘First Name and Location‘, ‘generatepress’ ) . ‘ *” id=”author” name=”author” type=”text” value=”‘ . esc_attr( $commenter[‘comment_author’] ) . ‘” size=”30″ />’,
…because that’s not working for me.
June 22, 2018 at 9:04 am #606180Tom
Lead DeveloperLead DeveloperCan you include your full function? Be sure to highlight the code and click the “code” button in the editor toolbar.
June 22, 2018 at 9:42 am #606220Randy
Certainly. I have this in functions.php (child theme):
//Change form placeholder 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__( 'First Name and Location', 'generatepress' ) . '</label><input placeholder="' . esc_attr__( 'First Name and location', '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" />', ); } //Kill URL in comment form add_action( 'after_setup_theme', 'tu_add_comment_url_filter' ); function tu_add_comment_url_filter() { add_filter( 'comment_form_default_fields', 'tu_disable_comment_url', 20 ); }
June 22, 2018 at 8:03 pm #606473Tom
Lead DeveloperLead DeveloperAnd what are you trying to do? Remove the URL field?
June 22, 2018 at 8:16 pm #606481Randy
Already have the URL removed; I included that part of the function in case there was any conflict causing the problem. Just trying to change the placeholder text as shown. Isn’t doing anything.
You can look at https://dev.thisistrue.com (which will go away as soon as this issue is resolved — I’m otherwise ready to move it to production, my largest site to move from Canvas to GP).
June 22, 2018 at 8:22 pm #606482Tom
Lead DeveloperLead DeveloperWhat are the contents of the
tu_disable_comment_url()
function?June 22, 2018 at 8:29 pm #606483Randy
function tu_disable_comment_url($fields) { unset($fields['url']); return $fields; }
June 22, 2018 at 8:30 pm #606484Tom
Lead DeveloperLead DeveloperTry this as your PHP:
function tu_adjust_comment_form_fields( $fields ) { return array( 'author' => '<label for="author" class="screen-reader-text">' . esc_html__( 'First Name and Location', 'generatepress' ) . '</label><input placeholder="' . esc_attr__( 'First Name and location', '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" />', ); } //Kill URL in comment form add_action( 'after_setup_theme', 'tu_add_comment_url_filter' ); function tu_add_comment_url_filter() { add_filter( 'comment_form_default_fields', 'tu_adjust_comment_form_fields', 20 ); }
June 22, 2018 at 9:01 pm #606495Randy
Whew! I’ll have to look really carefully at what changed, but that did it.
Thanks much.
P.S.: How old is your baby (in the photo) now?
June 23, 2018 at 9:29 am #606895Tom
Lead DeveloperLead DeveloperYou’re welcome!
She’s 2 now π
June 23, 2018 at 1:01 pm #607013Randy
Awesome.
-
AuthorPosts
- You must be logged in to reply to this topic.