How to customize Wordpress comment_form(); How to customize Wordpress comment_form(); wordpress wordpress

How to customize Wordpress comment_form();


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

ob_start();comment_form($args);$comment_form = ob_get_clean();//insert code to modify $comment_formecho $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         'label_submit'=>'Send',        // 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>',);comment_form($comments_args);

For more information: comment_form() documentation on WordPress Codex


I use functions.php to modify comments display. I don't 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.