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

Advertisements

Sr. Software Engineer

Tagged with: , , , ,
Posted in Wordpress
2 comments on “How Customizing Your Comment Form Using Hooks : Worddress
  1. Kim says:

    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.

  2. Aubrey says:

    Astounding job, you really helped me interpret the subject with ease.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: