Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9209113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:45:56+00:00 2026-06-18T00:45:56+00:00

I would like to customize the output of comment_form() function in WordPress. To edit

  • 0

I would like to customize the output of comment_form() function in WordPress.
To edit fields and textarea, I used the following code and all works fine.

<?php
    $req = get_option( 'require_name_email' );
    $fields =  array(
            // redefine author field
        'author' => '<p class="comment-form-author">' . '<label for="author">' . __( 'Name:' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label>' .
        '<div class="input-prepend"><span class="add-on"><i class="icon-user"></i></span><input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . 'aria-required="true"' . ' required /></p>',
        'email'  => '<p class="comment-form-email"><label for="email">' . __( 'Email Address:' ) . ( $req ? ' <span class="required">*</span><br/>' : '' ) . '</label>' . 
        '<div class="input-prepend"><span class="add-on"><i class="icon-envelope"></i></span><input required id="email" name="email" type="text" value="' . esc_attr(  $commenter['comment_author_email'] ) . '" size="30"' . 'aria-required="true"' . ' required /></div></p>',
        'url'  => '<p class="comment-form-url"><label for="url">' . __( 'Your Website:' ) . '</label>' . 
        '<div class="input-prepend"><span class="add-on"><i class="icon-globe"></i></span><input id="url" name="url" type="text" value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" /></div></p>'
        );
    $comments_args = array(
        'fields' => $fields,
            // redefine your own textarea (the comment body)
        'comment_field' => '<p class="comment-form-comment"><label for="comment">' . 'Comment' . '</label><textarea id="comment" name="comment" class="span12" rows="5" aria-required="true"></textarea></p>',
        );
    comment_form( $comments_args );
?>

This is the result:

Custom comment form

Now, I would like to add two CSS class (class="btn btn-primary") for submit button; how can I do that without using jQuery?

Note:

For the solution, please read comments about answer marked with green sign.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T00:45:57+00:00Added an answer on June 18, 2026 at 12:45 am

    As krizna said, you can modify your theme’s comments.php file to alter the output of comment_form(). I think that might be your best bet in this situation.

    If you take a look at the Function Reference for comment_form() in the Codex you’ll notice that you can only modify the ID for the submit button, and not the class. There are a few tickets on Trac regarding this:

    • http://core.trac.wordpress.org/ticket/20446
    • http://core.trac.wordpress.org/ticket/15015

    If modifying comments.php doesn’t work for you in this situation, you can try applying one of the patches.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've written a generic changegroup hook function that I would like to customize for
I would like to customize the following flash msg provided by devise in the
I would like to customize the background (and maybe the border too) of all
I have a 1920x1200 screen an would like to customize VS2008 code windows to
I would like to customize an off-the-shelf software that has a Lite Edition and
We are using JBoss 4.2. We would like to customize the session id which
I'm working on a website for a client, and I would like to customize
I would like to write a shell extensions to completely customize the display of
I would like to customize my titlebar, minimize-, maximize- and the close-button. So I
I use a SeekBar in my application and I would like to customize it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.