comments.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. /**
  3. * The template for displaying comments
  4. *
  5. * The area of the page that contains both current comments
  6. * and the comment form.
  7. *
  8. * @package WordPress
  9. * @subpackage Twenty_Sixteen
  10. * @since Twenty Sixteen 1.0
  11. */
  12. /*
  13. * If the current post is protected by a password and
  14. * the visitor has not yet entered the password we will
  15. * return early without loading the comments.
  16. */
  17. if ( post_password_required() ) {
  18. return;
  19. }
  20. ?>
  21. <div id="comments" class="comments-area">
  22. <?php if ( have_comments() ) : ?>
  23. <h2 class="comments-title">
  24. <?php
  25. $comments_number = get_comments_number();
  26. if ( 1 === $comments_number ) {
  27. /* translators: %s: post title */
  28. printf( _x( 'One thought on &ldquo;%s&rdquo;', 'comments title', 'twentysixteen' ), get_the_title() );
  29. } else {
  30. printf(
  31. /* translators: 1: number of comments, 2: post title */
  32. _nx(
  33. '%1$s thought on &ldquo;%2$s&rdquo;',
  34. '%1$s thoughts on &ldquo;%2$s&rdquo;',
  35. $comments_number,
  36. 'comments title',
  37. 'twentysixteen'
  38. ),
  39. number_format_i18n( $comments_number ),
  40. get_the_title()
  41. );
  42. }
  43. ?>
  44. </h2>
  45. <?php the_comments_navigation(); ?>
  46. <ol class="comment-list">
  47. <?php
  48. wp_list_comments( array(
  49. 'style' => 'ol',
  50. 'short_ping' => true,
  51. 'avatar_size' => 42,
  52. ) );
  53. ?>
  54. </ol><!-- .comment-list -->
  55. <?php the_comments_navigation(); ?>
  56. <?php endif; // Check for have_comments(). ?>
  57. <?php
  58. // If comments are closed and there are comments, let's leave a little note, shall we?
  59. if ( ! comments_open() && get_comments_number() && post_type_supports( get_post_type(), 'comments' ) ) :
  60. ?>
  61. <p class="no-comments"><?php _e( 'Comments are closed.', 'twentysixteen' ); ?></p>
  62. <?php endif; ?>
  63. <?php
  64. comment_form( array(
  65. 'title_reply_before' => '<h2 id="reply-title" class="comment-reply-title">',
  66. 'title_reply_after' => '</h2>',
  67. ) );
  68. ?>
  69. </div><!-- .comments-area -->