user2898224
user2898224

Reputation: 57

WordPress - Twenty Thirteen - Leave a Reply (comment) - can this be edited?

I have a question regarding the Leave a Reply section at the bottom of the Twenty Thirteen WordPress theme. At the bottom of a page, you will see the area that asks for your Name, Email, Website, and then an option to write in a Comment.

I am wondering if it is possible to change the word Website, to Agency. I looked in a couple files, but can't seem to find this area in the code. I've looked in the Comments.php, as well as the content.php file. At the bottom of the content.php file, I do see the area that I believe is the section that may need to be edited but unsure how to go about doing this.

Here is a screenshot of the area that I am talking about.

enter image description here

Upvotes: 1

Views: 893

Answers (3)

Lafif Astahdziq
Lafif Astahdziq

Reputation: 3976

You can add or modify the comment form field by wordpress filter through functions.php of your theme. Try to add this to your functions.php

function my_fields($fields) {
    // replace url with agency 
    $fields['url'] = '<p class="comment-form-agency"><label for="agency">' . __( 'Agency' ) . '</label> ' .
                     '<input id="agency" name="agency" type="text" value="" size="30" /></p>';
return $fields;
}
add_filter('comment_form_default_fields','my_fields');

or you can add agency input as new field

function my_fields($fields) {
        $fields['agency'] = '<p class="comment-form-agency"><label for="agency">' . __( 'Agency' ) . '</label> ' .
                         '<input id="agency" name="agency" type="text" value="" size="30" /></p>';
    return $fields;
    }
    add_filter('comment_form_default_fields','my_fields');

Upvotes: 1

user2189331
user2189331

Reputation:

In the Comments.php for the theme, replace the parameterless call to comment_form (at the bottom). You can pass in your modifications there. No need to modify the Core. See comment_form API reference.

Upvotes: 1

trevor
trevor

Reputation: 2300

@user2898224:

The file you are looking for is the WordPress core file 'wp-includes\comment-template.php'.

You need to change line #2058, which looks like this:

'url'    => '<p class="comment-form-url"><label for="url">' . __( 'Website' ) . '</label> ' .

All you have to do is change 'Website' to 'Agency' on this line.

Keep in mind that this change modifies a WordPress core file, so if you ever want to upgrade your WordPress installation, you will need to make the same change again after upgrading.

Modifiying WordPress core files is also not a very good idea, but in this case the change is small enough that you can get away with it.

In the event that you do not want to modify (nor should you) a WordPress core file, you can also do the following:

In the Twenty Thirteen theme's 'comments.php' file, replace this call to the comment_form function:

<?php comment_form(); ?>

With this block of code (and yes, all of this code is necessary):

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

    $comments_args = array(
        'fields' =>  $fields
    );

    comment_form( $comments_args );
?>

This may seem like a more complicated way to go about changing just one word on the comment form, but it will keep you from messing with any of the WordPress core files.

Upvotes: 3

Related Questions