How Customizing Your Comment Form Using Hooks : Worddress

Hello My Friends!
Hope you all are doing well :) :)
If you want to customizing the comment form fields, then you have no need to edit in wordpress core files, you can override the comment form html using hooks, just add given code into your theme function.php file and save file.

/* added code by raghunath */
function modify_comment_fields($fields){
    $commenter = wp_get_current_commenter();
    $req = get_option( 'require_name_email' );
    $aria_req = ( $req ? " aria-required='true'" : '' );
$fields =  array(
    'author' => '<p>' . '<label for="author">' . __( 'Name' ) .( $req ? '<span>*</span>' : '' ) . '</label> ' .
        '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . ' /></p>',
    'email'  => '<p><label for="email">' . __( 'Email' ) .( $req ? '<span>*</span>' : '' ) . '</label> ' .
        '<input id="email" name="email" type="text" value="' . esc_attr(  $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ' /></p>',
    'url'    => '<p><label for="url">' . __( 'Website' ) . '</label>' .
        '<input id="url" name="url" type="text" value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" /></p>'
);
    return $fields;
    }
  add_filter('comment_form_default_fields','modify_comment_fields');
 /* End the comment edit forms fields*/

Now you can easily edit the exist comment form.
Enjoy Code! | Enjoy My BLog

2 Replies to “How Customizing Your Comment Form Using Hooks : Worddress”

  1. Auto blogging is considered poorly by some popular bloggers, however the technology serves as the foundation for many highly used Web 2. To begin, open your Blogger dashboard, and go to Layout > Edit HTML.

Leave a Reply

Your email address will not be published. Required fields are marked *