Skip to main content
2 of 4
Extended the question
JoBe
  • 171
  • 2
  • 11

How do I change parameters without changing the core

How do I change a parameter/text that are specified in the core without editing the core?

For example, this is a part of of comment-template.php from the wp-includes directory:

$fields = apply_filters( 'comment_form_default_fields', $fields );

    $defaults = array(
        'fields'               => $fields,
        'comment_field'        => sprintf(
            '<p class="comment-form-comment">%s %s</p>',
            sprintf(
                '<label for="comment">%s</label>',
                _x( 'Comment', 'noun' )
            ),
            '<textarea id="comment" name="comment" cols="45" rows="8" maxlength="65525" required="required"></textarea>'
        ),

That's a part of the thingie that displays the comment form, and writes the word "Comment" above the text field.

Now, if I want to change the word Comment to Please leave a comment..., How do I do it?

I understand that some kind of hook need to be used and placed in the functions.php file, but there ends my knowledge, and just change the core file is a big NO-NO!

Edit:

On line 2438 (wp 5.4.2)

'title_reply'          => __( 'Leave a Reply' ),

I just changed it to;

        'title_reply

'          => __( '' ),

I just don't want to show it..

Line 2446

'label_submit'         => __( 'Post Comment' ),

changed it to:

'label_submit'         => __( ' Submit your thoughts...' ),

And finally, line 2536

echo apply_filters( 'comment_form_logged_in', $args['logged_in_as'], $commenter, $user_identity );

Changed it to

echo apply_filters( 'comment_form_logged_in', '' );

Don't want to display this either..

That's how I previously has changed the core comment-temple.php file.

How do I do it in the functions.php

(It will affect pages like: https://rainbowpets.org/rasmus/ )

JoBe
  • 171
  • 2
  • 11