Wordpress Comments Template


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



Copy this code and paste it in your HTML
  1. <?php
  2. $default_avatar = 'http://zacvineyard.com/blog/wp-content/themes/zac/images/default-avatar.png';
  3. ?>
  4. <a id="comments"></a>
  5. <h2>Comments</h2>
  6. <?php if($comments) : ?>
  7. <ol class="comments">
  8. <?php foreach($comments as $comment) : ?>
  9. <li id="comment-<?php comment_ID(); ?>" class="<?php if ($comment->user_id == 1) echo "authcomment";?>">
  10. <?php if ($comment->comment_approved == '0') : ?>
  11. <p>Your comment is awaiting approval</p>
  12. <?php endif; ?>
  13. <?php echo get_avatar(get_comment_author_email(), 48, $default_avatar); ?>
  14. <cite><h3><?php comment_author_link(); ?></h3> on <small><?php comment_date(); ?></small></cite><br />
  15. <?php comment_text(); ?>
  16. </li>
  17. <?php endforeach; ?>
  18. </ol>
  19. <?php endif; ?>
  20.  
  21. <?php if(comments_open()) : ?>
  22. <h2>Add Your Comment</h2>
  23. <?php if(get_option('comment_registration') && !$user_ID) : ?>
  24. <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 : ?>
  25. <form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
  26. <?php if($user_ID) : ?>
  27. <p>Logged in as <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a>. <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?action=logout" title="Log out of this account">Log out &raquo;</a></p>
  28. <?php else : ?>
  29. <p><input type="text" name="author" id="author" value="<?php echo $comment_author; ?>" size="22" tabindex="1" />
  30. <label for="author">Name <?php if($req) echo "(required)"; ?></label></p>
  31. <p><input type="text" name="email" id="email" value="<?php echo $comment_author_email; ?>" size="22" tabindex="2" />
  32. <label for="email">Email (will not be published<?php if($req) echo ", required"; ?>)</label></p>
  33. <p><input type="text" name="url" id="url" value="<?php echo $comment_author_url; ?>" size="22" tabindex="3" />
  34. <label for="url">Website</label></p>
  35. <?php endif; ?>
  36. <p><textarea name="comment" id="comment" rows="10" tabindex="4"></textarea></p>
  37. <?php //show_subscription_checkbox(); ?>
  38. <p><input name="submit" type="submit" id="submit" tabindex="5" value="Submit Comment" />
  39. <input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" /></p>
  40. <?php do_action('comment_form', $post->ID); ?>
  41. </form>
  42. <?php endif; ?>
  43. <?php else : ?>
  44. <p>The comments are closed.</p>
  45. <?php endif; ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.