How to Quickly and Easily Customize the WordPress Comments Form

How to Quickly and Easily Customize the WordPress Comments Form

Many WordPress themes utilize the standard WordPress comments form. Introduced in WordPress 3.0, it’s meant to be a simple tag to output a complete commenting form within a theme template. Making minor changes to the form might seem baffling at first, but it’s really not too difficult.

Step 1: Don’t hack the core.

Here’s the most important tip: Don’t edit the /wp-includes/comment-template.php file. Someone may have suggested it to you in the forums as the quickest way to customize the comments template, but it’s never really a good idea to edit the WordPress core files. There’s a better way.

Step 2: Edit the Comment Form Tag.

Open the file containing the comment form tag. Here’s what it looks like:

{code type=php}<?php comment_form() ?>

More than likely the theme file that you’re looking for is going to be comments.php.

There are some some different parameters you can pass to the function for modifying the form. The codex has several handy examples for editing the comments template. Let’s do a simple one.

FREE EBOOK
Your step-by-step roadmap to a profitable web dev business. From landing more clients to scaling like crazy.

By downloading this ebook I consent to occasionally receive emails from WPMU DEV.
We keep your email 100% private and do not spam.

FREE EBOOK
Plan, build, and launch your next WP site without a hitch. Our checklist makes the process easy and repeatable.

By downloading this ebook I consent to occasionally receive emails from WPMU DEV.
We keep your email 100% private and do not spam.

If you want to remove the HTML text that follows the form (“You may use these HTML tags and attributes…”), here’s how to modify the tag:

{code type=php}
<?php
$comments_args = array(

// remove “Text or HTML to be displayed after the set of comment fields”
‘comment_notes_after’ => ”,

);

comment_form($comments_args);
?>

Not so difficult, right? Now, let’s change the title of the comment form. By default it says “Leave a Reply”. Let’s change that to “Comment”.

{code type=php}
<?php
$comments_args = array(

// change “Leave a Reply” to “Comment”
‘title_reply’=>’Comment’,
);

comment_form($comments_args);
?>

You can change the text to be something more creative than “Comment”, such as “Discuss this post” or “Have something to say?”

The codex includes several more examples, but these simple ones should be enough to get you started. You can also rest assured that these quick edits to your theme’s comments file will be safe, even when you upgrade the WordPress core.

Tags: