• Hey,

    I have spent ages trying to figure out how to edit the ‘Your email address will not be published.’ – I think I did it once but then when I updated my changes went.

    I also wanted to make the comments box smaller but not had any luck figuring that out either.

    Thanks a lot for your help ??

Viewing 11 replies - 1 through 11 (of 11 total)
  • Moderator t-p

    (@t-p)

    see these guides:

    https://ottopress.com/2010/wordpress-3-0-theme-tip-the-comment-form/
    https://codex.www.ads-software.com/Function_Reference/comment_form

    I think I did it once but then when I updated my changes went.

    this the reason it is highly recommended in these forums that you create a child theme. That way, when you update your WordPress or theme, your customizations don’t get overwritten.

    It’s one of the default args to comment_form(); specifically, $args['comment_notes_before']. If you are hacking a template, just add that element to the args array that you pass to comment_form() and it will override the default.

    Alternatively, you can add a filter for the default args. See https://codex.www.ads-software.com/Function_Reference/comment_form for all the exciting details.

    I can’t find anyway to modify it from the Dashboard, though.

    (I see I took too long in answering! t-p’s suggestions are more direct & correct. Question: is there a way for me to delete a post to the forums?)

    Thread Starter Matt Lovett

    (@mdeluk)

    Sorry I am still confused..

    Below is my current comments.php page from my template.

    [Code moderated as per the Forum Rules. Please use the pastebin]

    Thread Starter Matt Lovett

    (@mdeluk)

    Sorry here is link to comments.php on pastebin

    https://pastebin.com/UEz7MV9j

    Moderator keesiemeijer

    (@keesiemeijer)

    change this:

    <?php 
    
    $your_fields =  array(
        'author' => '<p class="comment-form-author">' . '<label for="author">' . __( 'Name' ) . '</label> ' . ( $req ? '<span class="required">*</span>' : '' ) .               '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . ' /></p>',
        'email'  => '<p class="comment-form-email"><label for="email">' . __( 'Email' ) . '</label> ' . ( $req ? '<span class="required">*</span>' : '' ) . '<input id="email" name="email" type="text" value="' . esc_attr(  $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ' /></p>',
    );
    comment_form(array('fields' => $your_fields));
    ?>

    to this:

    <?php 
    
    $your_fields =  array(
        'comment_notes_before' => '<p class="comment-notes">' . __( 'Your email address will not be published.' ) . ( $req ? $required_text : '' ) . '</p>',
        'author' => '<p class="comment-form-author">' . '<label for="author">' . __( 'Name' ) . '</label> ' . ( $req ? '<span class="required">*</span>' : '' ) .               '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . ' /></p>',
        'email'  => '<p class="comment-form-email"><label for="email">' . __( 'Email' ) . '</label> ' . ( $req ? '<span class="required">*</span>' : '' ) . '<input id="email" name="email" type="text" value="' . esc_attr(  $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ' /></p>',
         'comment_field'        => '<p class="comment-form-comment"><label for="comment">' . _x( 'Comment', 'noun' ) . '</label><textarea id="comment" name="comment" cols="30" rows="8" aria-required="true"></textarea></p>',
    
    );
    comment_form(array('fields' => $your_fields));
    
     ?>

    In the new code you see “Your email address will not be published”.
    change it to what you want. The comment field will also be smaller. change cols="30" to the size you want

    Thread Starter Matt Lovett

    (@mdeluk)

    Hmm that did not work.

    I replaced the code like you said but the text for ‘your email address will not be published’ appeared twice and so did the comment box. The name and email box only appeared once though..

    Moderator t-p

    (@t-p)

    try this:

    <?php 
    
    $your_fields =  array(
    
        'author' => '<p class="comment-form-author">' . '<label for="author">' . __( 'Name' ) . '</label> ' . ( $req ? '<span class="required">*</span>' : '' ) .               '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . ' /></p>',
        'email'  => '<p class="comment-form-email"><label for="email">' . __( 'Email' ) . '</label> ' . ( $req ? '<span class="required">*</span>' : '' ) . '<input id="email" name="email" type="text" value="' . esc_attr(  $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ' /></p>',
         'comment_field'        => '<p class="comment-form-comment"><label for="comment">' . _x( 'Comment', 'noun' ) . '</label><textarea id="comment" name="comment" cols="30" rows="8" aria-required="true"></textarea></p>',
    
    'comment_notes_after' => '',
    	'title_reply' => __( 'YOUR TEXT HERE' ),
    
    );
    comment_form(array('fields' => $your_fields));
    
     ?>
    Thread Starter Matt Lovett

    (@mdeluk)

    Hmm strange I did that. this time it put your text here and just a comments box at the bottom?

    I replaced code correctly. any ideas?

    thanks for your help!

    Moderator t-p

    (@t-p)

    try this:

    <?php 
    
    $your_fields =  array(
    
        'author' => '<p class="comment-form-author">' . '<label for="author">' . __( 'Name' ) . '</label> ' . ( $req ? '<span class="required">*</span>' : '' ) .               '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . ' /></p>',
        'email'  => '<p class="comment-form-email"><label for="email">' . __( 'Email' ) . '</label> ' . ( $req ? '<span class="required">*</span>' : '' ) . '<input id="email" name="email" type="text" value="' . esc_attr(  $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ' /></p>',
         'comment_field'        => '<p class="comment-form-comment"><label for="comment">' . _x( 'Comment', 'noun' ) . '</label><textarea id="comment" name="comment" cols="30" rows="8" aria-required="true"></textarea></p>',
    'comment_notes_before' => '<p class="comment-notes">' . __( '' ) . '</p>',
    'comment_notes_after' => '',
    	'title_reply' => __( 'YOUR TEXT HERE' ),
    
    );?>
    
    <?php
    comment_form(array('fields' => $your_fields));
    
     ?>
    Thread Starter Matt Lovett

    (@mdeluk)

    Hey,

    No same problem as before??

    I just crossed this problem myself and I found the solution!
    I looked at the reference here:https://codex.www.ads-software.com/Function_Reference/comment_form

    For example:

    title_reply
    (string) (optional) The title of comment form (when not replying to a comment, see comment_form_title).
    Default: __( ‘Leave a Reply’ )

    It means we insert the title_reply in the array like this:

    comment_form(array('title_reply'=>'Add Comment')); (notice that default is Leave a Reply, now it will be changed to “Add Comment”)

    For the fields (Name/Email/Url) I copy pasted the following code just before calling the comment_form():

    $fields =  array(
    	'author' => '<p class="comment-form-author">' . '<label for="author">' . __( 'Name' ) . '</label> ' . ( $req ? '<span class="required">*</span>' : '' ) .
    	            '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . ' /></p>',
    	'email'  => '<p class="comment-form-email"><label for="email">' . __( 'Email' ) . '</label> ' . ( $req ? '<span class="required">*</span>' : '' ) .
    	            '<input id="email" name="email" type="text" value="' . esc_attr(  $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ' /></p>',
    	'url'    => '<p class="comment-form-url"><label for="url">' . __( 'Website' ) . '</label>' .
    	            '<input id="url" name="url" type="text" value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" /></p>',
    );

    then I started to change the HTML markup in $fields = array (….

    ex. <p class=”comment-form-author”> changed to <div class=”comment-form-author”>

    and then added to the the comment_form(array.. like this:

    comment_form(array('title_reply'=>'Add Comment', 'fields' => $fields));

    and that’s it

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Your email address will not be published. – editing text’ is closed to new replies.