Site logo

Archived topic

Edit comment cookies text "Save my name, email, and website . . ."

6 replies · Started by Flavio on May 27, 2018

Viewing posts 1–7 of 7

Hello,

I'd like to edit the cookie opt-in checkbox text "Save my name, email, and website in this browser for the next time I comment."

Basically I'd like to remove the word "website" as my comment post section does not have a Website field.

Any help is greatly appreciated.

Thanks.

Hi Flavio,

You can do so with the Loco Translate plugin. I just tried it and it works fine :) Keep in mind that this text is coming from WordPress and not GeneratePress (or any theme); the theme just controls how it looks.

https://wordpress.org/plugins/loco-translate/

Cheers!
Lyle

Thanks Lyle.

While plugins are great, I am trying to limit their number as much as possible. I'm a minimalist :-)

I just need to either find the exact location of this text (file name) or simply edit via CSS. I can take care of the rest afterwards.

Again, thank you for the reply and for the plugin tip!

Flavio

Hi there,

Give this a shot:

add_filter( 'comment_form_default_fields', 'tu_filter_comment_fields', 20 );
function tu_filter_comment_fields( $fields ) {
    $commenter = wp_get_current_commenter();

    $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>';

    return $fields;
}

Unfortunately, it's not a "text" file but in one of the core WP php files, the editing of which is not recommended as they will be negated on the next update.

Once you do the edit with Loco Translate, you can delete the plugin as it creates a file with the change that is update safe :)

Thank you Tom and Lyle.

I didn't use your suggestions, but I was able to make the edit I needed (remove the word "website" from the opt-in label text).

Your help was very much appreciated.

Thank you!

No problem :)

This archived topic is closed to new replies.