Loading

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>

Hope you enjoyed the tutorial , let me know your feedback!

1 Star2 Stars3 Stars4 Stars5 Stars (3 votes, average: 4.67 out of 5)
Loading ... Loading ...

You might want to read these as well

Loading...







How to modify the WordPress comment Form

Joshu is the Founder of the OrangeCopper Webmaster's Community, He had been designing & developing web applications as a freelancer in this field for the past 9 years. OC was born in 2002 December and since 2004 Joshu had been Blogging on the Web about what he learned the Hard way, So that you could learn it the Easy Way. Follow OrangeCopper on Twitter and you would be Auto-Followed.


  • abard
    ts and picking up new ones, secondly, many of the quests in the same areawow powerleveling involve killing or collecting items near the same location, queuing quests will make it easier to get all of them done
  • abard
    Expanding your cube space should be your first major purchase in AION kinah. Every class is capable of leveling easily with the gear and weapons collected along the way through quest rewards. Even though you may get a lucky drop that is a perfect upgrade for your class, you will probably reap bigger rewards in the long run by selling it to another, less savvy player.
  • It is my great pleasure to visit your website and to enjoy your excellent post here.I like that very much. I can feel that you paid much attention for those articles, as all of them make sense and are very useful. Thanks so much for sharing. I can be very good reader&listener discount cheap jordan shoes , if you are same searching for all to be good.
  • I was looking for this solution for some days. I was stuck with this problem. This article will be very useful for me.
  • ongamesite
    Hi every friends,

    Did you like play online flash games and nice VIDEO ^_^. OK! If you are interesting with it.

    Just do a click http://www.ongamesite.com. Good luck!!!


    Internet games,Computer games,Windows games and nice video
  • I am also new in PHP and this tutorial will help me a lot. I would like to thank you for the chance.
  • Hi Joshu, I am new to editing PHP code, and am trying to delete the "No comments" text on the Wordpress page. Would you know which code I would need to edit or delete please?

    Jessica
  • Jess
    Worked it out seconds after posting :-)

    You delete only the text No comments in the below code-

    if ( post_password_required() ) : ?>

    <?php _e('Enter your password to view comments.'); ?>


    <?php return; endif; ?>

    <?php comments_number(__('No Comments'), __('1 Comment'), __('% Comments')); ?>
    <?php if ( comments_open() ) : ?>
    <a href="#postcomment" title="<?php _e("Leave a comment"); ?>">»
    <?php endif; ?>

  • Siby Thomas
    Nice Structured and detailed explanation, Thankyou !
  • Thx Siby for the comment :)
blog comments powered by Disqus