comments.php 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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 Dara
  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. $comments_number = get_comments_number();
  28. if ( 1 === $comments_number ) {
  29. /* translators: %s: post title */
  30. printf( esc_html_x( 'One thought on &ldquo;%s&rdquo;', 'comments title', 'dara' ), get_the_title() );
  31. } else {
  32. printf(
  33. /* translators: 1: number of comments, 2: post title */
  34. esc_html( _nx(
  35. '%1$s thought on &ldquo;%2$s&rdquo;',
  36. '%1$s thoughts on &ldquo;%2$s&rdquo;',
  37. $comments_number,
  38. 'comments title',
  39. 'dara'
  40. ) ),
  41. number_format_i18n( $comments_number ),
  42. get_the_title()
  43. );
  44. }
  45. ?>
  46. </h2>
  47. <?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // Are there comments to navigate through? ?>
  48. <nav id="comment-nav-above" class="navigation comment-navigation" role="navigation">
  49. <h2 class="screen-reader-text"><?php esc_html_e( 'Comment navigation', 'dara' ); ?></h2>
  50. <div class="nav-links">
  51. <div class="nav-previous"><?php previous_comments_link( esc_html__( 'Older Comments', 'dara' ) ); ?></div>
  52. <div class="nav-next"><?php next_comments_link( esc_html__( 'Newer Comments', 'dara' ) ); ?></div>
  53. </div>
  54. </nav>
  55. <?php endif; // Check for comment navigation. ?>
  56. <ol class="comment-list">
  57. <?php
  58. wp_list_comments( array(
  59. 'style' => 'ol',
  60. 'short_ping' => true,
  61. ) );
  62. ?>
  63. </ol>
  64. <?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // Are there comments to navigate through? ?>
  65. <nav id="comment-nav-below" class="navigation comment-navigation" role="navigation">
  66. <h2 class="screen-reader-text"><?php esc_html_e( 'Comment navigation', 'dara' ); ?></h2>
  67. <div class="nav-links">
  68. <div class="nav-previous"><?php previous_comments_link( esc_html__( 'Older Comments', 'dara' ) ); ?></div>
  69. <div class="nav-next"><?php next_comments_link( esc_html__( 'Newer Comments', 'dara' ) ); ?></div>
  70. </div>
  71. </nav>
  72. <?php
  73. endif; // Check for comment navigation.
  74. endif; // Check for have_comments().
  75. // If comments are closed and there are comments, let's leave a little note, shall we?
  76. if ( ! comments_open() && get_comments_number() && post_type_supports( get_post_type(), 'comments' ) ) : ?>
  77. <p class="no-comments"><?php esc_html_e( 'Comments are closed.', 'dara' ); ?></p>
  78. <?php
  79. endif;
  80. comment_form();
  81. ?>
  82. </div><!-- #comments -->