Wordpress Comment Form


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. add_filter( 'comment_form_defaults', 'my_comment_defaults');
  2. function my_comment_defaults($defaults) {
  3. $req = get_option( 'require_name_email' );
  4. $aria_req = ( $req ? " aria-required='true'" : '' );
  5. $defaults = array(
  6. 'fields' => array(
  7. 'author' => '<div><label for="author">' . __( 'Name' ) . ( $req ? '<span class="required">*</span>' : '' ) . '</label> ' . '<input id="author" name="author" placeholder="your name" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . ' /></div>',
  8. 'email' => '<div><label for="email">' . __( 'Email' ) . ( $req ? '<span class="required">*</span>' : '' ) . '</label> ' . '<input id="email" name="email" placeholder="[email protected]" type="email" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ' /></div>'),
  9. 'comment_field' => '<div><label for="comment">' . _x( 'Comment', 'noun' ) . '</label><textarea id="comment" name="comment" cols="45" rows="8" aria-required="true" placeholder="your comment"></textarea></div>',
  10.  
  11. 'must_log_in' => '<p class="must-log-in">' . sprintf( __( 'You must be <a href="%s">logged in</a> to post a comment.' ), wp_login_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '</p>',
  12.  
  13. 'logged_in_as' => '<p class="logged-in-as">' . sprintf( __( 'Logged in as <a href="%1$s">%2$s</a>. <a href="%3$s" title="Log out of this account">Log out?</a>' ), admin_url( 'profile.php' ), $user_identity, wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '</p>',
  14.  
  15. 'comment_notes_before' => '<fieldset>',
  16.  
  17. 'comment_notes_after' => '</fieldset>',
  18.  
  19. 'id_form' => 'commentform',
  20.  
  21. 'id_submit' => 'submit',
  22.  
  23. 'title_reply' => __( 'Leave a Comment' ),
  24.  
  25. 'title_reply_to' => __( 'Leave a Reply %s' ),
  26.  
  27. 'cancel_reply_link' => __( 'Cancel reply' ),
  28.  
  29. 'label_submit' => __( 'Comment' ),
  30.  
  31. );
  32.  
  33. return $defaults;
  34. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.