comments.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /**
  3. * The template for displaying comments.
  4. *
  5. * This is the template that displays the area of the page that contains both the current comments
  6. * and the comment form.
  7. *
  8. * @link https://codex.wordpress.org/Template_Hierarchy
  9. *
  10. * @package TextBook
  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 // You can start editing here -- including this comment!
  23. if ( have_comments() ) : ?>
  24. <h2 class="comments-title">
  25. <?php printf( _nx( '%1$s Comment', '%1$s Comments', get_comments_number(), 'comments title', 'textbook' ), number_format_i18n( get_comments_number() ) ); ?>
  26. </h2>
  27. <ol class="comment-list">
  28. <?php wp_list_comments( array(
  29. 'style' => 'ol',
  30. 'short_ping' => true,
  31. ) ); ?>
  32. </ol>
  33. <?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // Are there comments to navigate through? ?>
  34. <nav id="comment-nav-below" class="navigation comment-navigation" role="navigation">
  35. <h2 class="screen-reader-text"><?php esc_html_e( 'Comment navigation', 'textbook' ); ?></h2>
  36. <div class="nav-links">
  37. <div class="nav-previous"><?php previous_comments_link( esc_html__( 'Older Comments', 'textbook' ) ); ?></div>
  38. <div class="nav-next"><?php next_comments_link( esc_html__( 'Newer Comments', 'textbook' ) ); ?></div>
  39. </div>
  40. </nav>
  41. <?php endif; // Check for comment navigation. ?>
  42. <?php endif; // Check for have_comments(). ?>
  43. <?php // If comments are closed and there are comments, let's leave a little note, shall we?
  44. if ( ! comments_open() && get_comments_number() && post_type_supports( get_post_type(), 'comments' ) ) : ?>
  45. <p class="no-comments"><?php esc_html_e( 'Comments are closed.', 'textbook' ); ?></p>
  46. <?php endif; ?>
  47. <?php comment_form(); ?>
  48. </div><!-- #comments -->