How to modify the WordPress comment Form

How to modify the WordPress comment Form

About: How to modify the WordPress comment Form, modify wordpress comment form, edit wordpress comment, delete wordpress comment, remove website entry from wordpress comment, remove name from wp comment form, remove name from wordpress comment.

Code Of the comment.php that i had in my theme, here the section marked in red is the “Form” section that needs to be edited.

<!– You can start editing here. –>
<?php if ( have_comments() ) : ?>
<h3 id=”comments”><?php comments_number(‘No Responses’, ‘One Response’, ‘% Responses’ );?> to &#8220;<?php the_title(); ?>&#8221;</h3>
<ol>
<?php wp_list_comments(‘avatar_size=60’); ?>
</ol>
<div>
<div>
<?php previous_comments_link() ?>
</div>
<div>
<?php next_comments_link() ?>
</div>
</div>
<?php else : // this is displayed if there are no comments so far ?>
<?php if (‘open’ == $post->comment_status) : ?>
<!– If comments are open, but there are no comments. –>
<?php else : // comments are closed ?>
<!– If comments are closed. –>
<p>Comments are closed.</p>
<?php endif; ?>
<?php endif; ?>
<?php if (‘open’ == $post->comment_status) : ?>
<div id=”respond”>
<h3>
<?php comment_form_title( ‘Leave a Reply’, ‘Leave a Reply to %s’ ); ?>
</h3>
<div> <small>
<?php cancel_comment_reply_link(); ?>
</small> </div>
<?php if ( get_option(‘comment_registration’) && !$user_ID ) : ?>
<p>You must be <a href=”<?php echo get_option(‘siteurl’); ?>/wp-login.php?redirect_to=<?php echo urlencode(get_permalink()); ?>”>logged in</a> to post a comment.</p>
<?php else : ?>
<form action=”<?php echo get_option(‘siteurl’); ?>/wp-comments-post.php” method=”post” id=”commentform”>
<?php if ( $user_ID ) : ?>
<p>Logged in as <a href=”<?php echo get_option(‘siteurl’); ?>/wp-admin/profile.php”><?php echo $user_identity; ?></a>. <a href=”<?php echo wp_logout_url(get_permalink()); ?>” title=”Log out of this account”>Log out &raquo;</a></p>
<?php else : ?>
<p>
<input type=”text” name=”author” id=”author” value=”<?php echo $comment_author; ?>” size=”22″ tabindex=”1″ <?php if ($req) echo “aria-required=’true'”; ?> />
<label for=”author”><small>Name
<?php if ($req) echo “(required)”; ?>
</small></label>
</p>
<p>
<input type=”text” name=”email” id=”email” value=”<?php echo $comment_author_email; ?>” size=”22″ tabindex=”2″ <?php if ($req) echo “aria-required=’true'”; ?> />
<label for=”email”><small>Mail (will not be published)
<?php if ($req) echo “(required)”; ?>
</small></label>
</p>
<p>
<input type=”text” name=”url” id=”url” value=”<?php echo $comment_author_url; ?>” size=”22″ tabindex=”3″ />
<label for=”url”><small>Website</small></label>
</p>
<?php endif; ?>
<!–<p><small><strong>XHTML:</strong> You can use these tags: <code><?php echo allowed_tags(); ?></code></small></p>–>
<p>
<textarea name=”comment” id=”comment” cols=”100%” rows=”10″ tabindex=”4″></textarea>
</p>
<p>
<input name=”submit” type=”submit” id=”submit” tabindex=”5″ value=”Submit Comment” />
<?php comment_id_fields(); ?>
</p>
<?php do_action(‘comment_form’, $post->ID); ?>
</form>
<?php endif; // If registration required and not logged in ?>
</div>
<?php endif; // if you delete this the sky will fall on your head ?>
<div style=”clear: both;”></div>

How to: Remove the “Comments are closed Notice” So the Form part is the part of the wordpress comment code that is of our interest to edit. so what all modifications could be made to this comments section. usually when comments are disabled it shows a message on the page as ” <p>Comments are closed.</p> This looks a bit unprofessional, so this needs to be removed, do a ctrl + F and find the section and remove part  <p>Comments are closed.</p> and replace with <p> </p>

How to: Edit the Comment Form . Some websites would be of a kind where in the comment form would only require website and name, while some require only name and email, while some wanted to make it simple and just require the name only. Here is the form part and i will break up the highlighted part into 3 name, email and website. Just remove the section from the code that you dont want. simple as that.

Author Name

<p>
<input type=”text” name=”author” id=”author” value=”<?php echo $comment_author; ?>” size=”22″ tabindex=”1″ <?php if ($req) echo “aria-required=’true'”; ?> />
<label for=”author”><small>Name
<?php if ($req) echo “(required)”; ?>
</small></label>
</p>

Author Email

<p>
<input type=”text” name=”email” id=”email” value=”<?php echo $comment_author_email; ?>” size=”22″ tabindex=”2″ <?php if ($req) echo “aria-required=’true'”; ?> />
<label for=”email”><small>Mail (will not be published)
<?php if ($req) echo “(required)”; ?>
</small></label>
</p>

Comment Author website

<p>
<input type=”text” name=”url” id=”url” value=”<?php echo $comment_author_url; ?>” size=”22″ tabindex=”3″ />
<label for=”url”><small>Website</small></label>
</p>

Let me know your thoughts. Hope you enjoyed the tutorial on How to modify the WordPress comment Form

71 Comments

  1. Siby Thomas March 7, 2010
    • admin March 8, 2010
  2. admin April 14, 2010
  3. admin September 17, 2010
  4. indam November 10, 2010
    • admin November 10, 2010
  5. Outsource web design January 20, 2011
  6. Anonymous February 3, 2011
    • admin February 3, 2011
  7. hugo February 12, 2011
    • Joshu February 13, 2011
  8. banger February 16, 2011
  9. Finca Mallorca February 21, 2011
  10. Cristian Olteanu March 7, 2011
  11. Web Design Rotherham March 11, 2011
  12. omegaman66 March 11, 2011
  13. kalsoom@web design c March 31, 2011
    • Joshu March 31, 2011
  14. Anonymous April 4, 2011
  15. Cyclist Jersey Paolo April 19, 2011
  16. Anonymous May 13, 2011
  17. Stan Thieklin June 3, 2011
  18. waqas July 16, 2011
  19. English grammar exer July 28, 2011
  20. Airport Taxi July 29, 2011
  21. Andrewmleczny August 9, 2011
  22. seo1 September 29, 2011
  23. web design doncaster October 16, 2011
  24. AtInWebDesign October 20, 2011
  25. InWebDesign October 20, 2011
  26. AtInWebDesign October 20, 2011
  27. your web hosting October 24, 2011
  28. gimpy captcha October 30, 2011
  29. Host guru October 30, 2011
  30. joomla development c October 31, 2011
  31. snow throwers karche November 13, 2011
  32. NAS System November 17, 2011
  33. diets that work fast November 22, 2011
  34. Jessika November 26, 2011
  35. fiber December 5, 2011
  36. video clips December 8, 2011
  37. 5 mistakes December 12, 2011
  38. heimarbeit December 14, 2011
  39. organic gardener December 17, 2011
  40. Hollow Ichigo Contac December 17, 2011
  41. Elliott Archibold December 21, 2011
  42. cashinghub January 15, 2012
  43. Michelle Newman January 20, 2012
  44. John Abraham January 31, 2012
  45. Poker Netzwer January 31, 2012
  46. Bruce Griffith February 8, 2012
  47. Asho February 12, 2012
  48. tngku March 22, 2012
  49. Kaufland March 25, 2012
  50. burberry May 3, 2012
  51. RcHelicopter May 25, 2012
  52. venario June 6, 2012
  53. pkv versicherungsver June 7, 2012
  54. books store June 9, 2012
  55. free June 10, 2012
  56. De F.L.A.M. - La Chi June 11, 2012
  57. dog boarding in sing June 14, 2012
  58. windows 7 July 11, 2012
  59. Wayne July 12, 2012
  60. Audio Editing Softwa July 14, 2012
  61. captcha killer July 22, 2012
  62. seo facebook twitter September 4, 2012
  63. it September 10, 2012
  64. christian November 4, 2012
  65. Rehmat December 6, 2012