added comments template and comments function in single.php
authorAnthony Talarico <talarico@gaslightmedia.com>
Thu, 14 Jan 2016 18:08:24 +0000 (13:08 -0500)
committerAnthony Talarico <talarico@gaslightmedia.com>
Thu, 14 Jan 2016 18:09:01 +0000 (13:09 -0500)
root/comments.php [new file with mode: 0644]
root/single.php

diff --git a/root/comments.php b/root/comments.php
new file mode 100644 (file)
index 0000000..353cd14
--- /dev/null
@@ -0,0 +1,89 @@
+<?php
+/**
+ * The template for displaying comments
+ *
+ * The area of the page that contains both current comments
+ * and the comment form.
+ *
+ * @package WordPress
+ * @subpackage Twenty_Fifteen
+ * @since Twenty Fifteen 1.0
+ */
+if ( ! function_exists( 'twentyfifteen_comment_nav' ) ) :
+/**
+ * Display navigation to next/previous comments when applicable.
+ *
+ * @since Twenty Fifteen 1.0
+ */
+function twentyfifteen_comment_nav() {
+    // Are there comments to navigate through?
+    if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) :
+?>
+<nav class="navigation comment-navigation" role="navigation">
+    <h2 class="screen-reader-text"><?php _e( 'Comment navigation', 'twentyfifteen' ); ?></h2>
+    <div class="nav-links">
+        <?php
+    if ( $prev_link = get_previous_comments_link( __( 'Older Comments', 'twentyfifteen' ) ) ) :
+    printf( '<div class="nav-previous">%s</div>', $prev_link );
+    endif;
+
+    if ( $next_link = get_next_comments_link( __( 'Newer Comments', 'twentyfifteen' ) ) ) :
+    printf( '<div class="nav-next">%s</div>', $next_link );
+    endif;
+        ?>
+    </div><!-- .nav-links -->
+</nav><!-- .comment-navigation -->
+<?php
+    endif;
+}
+endif;
+/*
+ * If the current post is protected by a password and
+ * the visitor has not yet entered the password we will
+ * return early without loading the comments.
+ */
+if ( post_password_required() ) {
+    return;
+}
+?>
+
+<div id="comments" class="comments-area">
+
+    <?php if ( have_comments() ) : ?>
+    <h2 class="comments-title">
+        <?php
+        printf( _nx( 'One thought on &ldquo;%2$s&rdquo;', '%1$s thoughts on &ldquo;%2$s&rdquo;', get_comments_number(), 'comments title', 'twentyfifteen' ),
+               number_format_i18n( get_comments_number() ), get_the_title() );
+        ?>
+    </h2>
+
+    <?php twentyfifteen_comment_nav(); ?>
+
+    <ol class="comment-list">
+        <?php
+        wp_list_comments( array(
+            'style'       => 'ol',
+            'short_ping'  => true,
+            'avatar_size' => 56,
+        ) );
+        ?>
+    </ol><!-- .comment-list -->
+
+    <?php twentyfifteen_comment_nav(); ?>
+
+    <?php endif; // have_comments() ?>
+
+    <?php
+    // If comments are closed and there are comments, let's leave a little note, shall we?
+    if ( ! comments_open() && get_comments_number() && post_type_supports( get_post_type(), 'comments' ) ) :
+    ?>
+    <p class="no-comments"><?php _e( 'Comments are closed.', 'twentyfifteen' ); ?></p>
+    <?php endif; ?>
+
+    <?php comment_form(
+    array(
+        'class_submit' => 'button'
+    )
+); ?>
+
+</div><!-- .comments-area -->
index 544afa5..9e01332 100644 (file)
             </div><!--/.row .blog-post-container-->
             <?php endwhile; ?>
             <?php else: ?>
+            <?php if ( comments_open() || get_comments_number() ) :
+            comments_template();
+            endif; ?>
+        </div>
+    </div>
+    </div>
+</div>
+<?php endwhile; ?>
+<?php else: ?>
             <div id="post-404" class="noposts">
                 <p><?php _e('Sorry, no results were found.');?></p>
             </div><!-- /#post-404 -->