Viewing 12 replies - 1 through 12 (of 12 total)
  • Hello,

    Add the below code to the functions.php file of the child theme. Modify the code as per your need –

    function placeholder_comment_form_fields($fields) {
        $replace_author = __('Your Name', 'yourdomain');
        $replace_email = __('Your Email', 'yourdomain');
        $replace_url = __('Your Website', 'yourdomain');
        
        $fields['author'] = '<p class="comment-form-author">' . '<label for="author">' . __( 'Name', 'yourdomain' ) . '</label> ' . ( $req ? '<span class="required">*</span>' : '' ) .
                        '<input id="author" name="author" type="text" placeholder="'.$replace_author.'" value="' . esc_attr( $commenter['comment_author'] ) . '" size="20"' . $aria_req . ' /></p>';
                        
        $fields['email'] = '<p class="comment-form-email"><label for="email">' . __( 'Email', 'yourdomain' ) . '</label> ' .
        ( $req ? '<span class="required">*</span>' : '' ) .
        '<input id="email" name="email" type="text" placeholder="'.$replace_email.'" value="' . esc_attr(  $commenter['comment_author_email'] ) .
        '" size="30"' . $aria_req . ' /></p>';
        
        $fields['url'] = '<p class="comment-form-url"><label for="url">' . __( 'Website', 'yourdomain' ) . '</label>' .
        '<input id="url" name="url" type="text" placeholder="'.$replace_url.'" value="' . esc_attr( $commenter['comment_author_url'] ) .
        '" size="30" /></p>';
        
        return $fields;
    }
    add_filter('comment_form_default_fields','placeholder_comment_form_fields');
    Thread Starter natasha006

    (@natasha006)

    Thanks dear Amit,

    I could not make a change by code.
    Please assist me more what exactly I should change that is effective.

    Replace yourdomain with oceanwp and edit the text Your Name, Your Email, Your Website as per your need.
    Add this code to the functions.php file of the oceanwp child theme.

    Thread Starter natasha006

    (@natasha006)

    Thanks for your reply.

    I added this code to the functions.php of my child theme:

    function placeholder_comment_form_fields($fields) {
        $replace_author = __('test', 'oceanwp');
        $replace_email = __('test', 'oceanwp');
        $replace_url = __('test', 'oceanwp');
        
        $fields['author'] = '<p class="comment-form-author">' . '<label for="author">' . __( 'Name', 'yourdomain' ) . '</label> ' . ( $req ? '<span class="required">*</span>' : '' ) .
                        '<input id="author" name="author" type="text" placeholder="'.$replace_author.'" value="' . esc_attr( $commenter['comment_author'] ) . '" size="20"' . $aria_req . ' /></p>';
                        
        $fields['email'] = '<p class="comment-form-email"><label for="email">' . __( 'Email', 'yourdomain' ) . '</label> ' .
        ( $req ? '<span class="required">*</span>' : '' ) .
        '<input id="email" name="email" type="text" placeholder="'.$replace_email.'" value="' . esc_attr(  $commenter['comment_author_email'] ) .
        '" size="30"' . $aria_req . ' /></p>';
        
        $fields['url'] = '<p class="comment-form-url"><label for="url">' . __( 'Website', 'yourdomain' ) . '</label>' .
        '<input id="url" name="url" type="text" placeholder="'.$replace_url.'" value="' . esc_attr( $commenter['comment_author_url'] ) .
        '" size="30" /></p>';
        
        return $fields;
    }
    add_filter('comment_form_default_fields','placeholder_comment_form_fields');

    Please if is possible to check that is correct or not. Because I can’t see any change on the live site.

    Did you clear the cache after adding the code? It should work. Can you link to the site for which you have added the code?

    Thread Starter natasha006

    (@natasha006)

    I have not any caching plugin.

    https://prnt.sc/nfu0x2

    Thread Starter natasha006

    (@natasha006)

    Hi,

    Texts can be Changeable by ‘SAY WHAT‘ Plugin.
    If Change be by functions.php is very good!

    Thread Starter natasha006

    (@natasha006)

    Hi dear @apprimit
    have you checked the site?

    Do you want to translate the placeholder or want to change it? For translation, you can use Loco translate plugin or edit the Pot file under oceanwp > languages folder using a PoEdit tool.

    Thread Starter natasha006

    (@natasha006)

    Thanks @apprimit

    No translate.
    I want to change placeholder text only.

    Thread Starter natasha006

    (@natasha006)

    Hi dear @apprimit

    I don’t want to translate placeholder text.
    I want to change the text only.

    Thanks

    Sorry, but I couldn’t find a solution for it. I’ll update you when I’ll find a solution for it.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Change Comment form text’ is closed to new replies.