comments.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 AltoFocus
  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
  23. // You can start editing here -- including this comment!
  24. if ( have_comments() ) : ?>
  25. <h2 class="comments-title">
  26. <?php
  27. printf( // WPCS: XSS OK.
  28. esc_html( _nx( '%1$s Comment', '%1$s Comments', get_comments_number(), 'comments title', 'altofocus' ) ),
  29. number_format_i18n( get_comments_number() )
  30. );
  31. ?>
  32. </h2>
  33. <ol class="comment-list">
  34. <?php
  35. wp_list_comments( array(
  36. 'style' => 'ol',
  37. 'short_ping' => true,
  38. 'avatar_size' => 64,
  39. ) );
  40. ?>
  41. </ol>
  42. <?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // Are there comments to navigate through? ?>
  43. <nav id="comment-nav-below" class="navigation comment-navigation" role="navigation">
  44. <h2 class="screen-reader-text"><?php esc_html_e( 'Comment navigation', 'altofocus' ); ?></h2>
  45. <div class="nav-links">
  46. <div class="nav-previous"><?php previous_comments_link( esc_html__( 'Older Comments', 'altofocus' ) ); ?></div>
  47. <div class="nav-next"><?php next_comments_link( esc_html__( 'Newer Comments', 'altofocus' ) ); ?></div>
  48. </div>
  49. </nav>
  50. <?php
  51. endif; // Check for comment navigation.
  52. endif; // Check for have_comments().
  53. // If comments are closed and there are comments, let's leave a little note, shall we?
  54. if ( ! comments_open() && get_comments_number() && post_type_supports( get_post_type(), 'comments' ) ) : ?>
  55. <p class="no-comments"><?php esc_html_e( 'Comments are closed.', 'altofocus' ); ?></p>
  56. <?php
  57. endif;
  58. // Show comment form
  59. comment_form();
  60. ?>
  61. </div><!-- #comments -->