php – How to customize WordPress comment_form();

php – How to customize WordPress comment_form();

If all else fails, in comments.php in your theme directory,
change comment_form($args); to

$comment_form = ob_get_clean();
//insert code to modify $comment_form
echo $comment_form;

I used this to change the submit button to an image button.

Simple example how to change some comment form fields.

$comments_args = array(
        // change the title of send button 
        // change the title of the reply section
        title_reply=>Write a Reply or Comment,
        // remove Text or HTML to be displayed after the set of comment fields
        comment_notes_after => ,
        // redefine your own textarea (the comment body)
        comment_field => <p class=comment-form-comment><label for=comment> . _x( Comment, noun ) . </label><br /><textarea id=comment name=comment aria-required=true></textarea></p>,


For more information: comment_form() documentation on WordPress Codex

php – How to customize WordPress comment_form();

I use functions.php to modify comments display. I dont know if it is the way things are done now (last site that I was developing with WP and needed comments was in 2009 ;)), but here it is (place it in functions.php file!:

function THEMENAME_comment($comment, $args, $depth) {
  $GLOBALS[comment] = $comment;
  *your comment display code*

Remember to create pingback theme aswell. You do it similar to comments, only difference is the first line:

function THEMENAME_pings($comment, $args, $depth)

Other way may be using comments_template.

Leave a Reply

Your email address will not be published.