Load comments template only when comments are open or there's at least one comment

To be consistent with single.php and to ensure that an empty div (<div
id="comments" class="comments-area">) isn't outputted when both
comments are closed and there aren't any comments.
This commit is contained in:
David Ensinger 2013-01-04 16:09:37 -05:00
parent 56023b2194
commit cfb7f7fcdf
2 changed files with 10 additions and 2 deletions

View File

@ -109,7 +109,11 @@ get_header();
</footer><!-- .entry-meta --> </footer><!-- .entry-meta -->
</article><!-- #post-<?php the_ID(); ?> --> </article><!-- #post-<?php the_ID(); ?> -->
<?php comments_template(); ?> <?php
// If comments are open or we have at least one comment, load up the comment template
if ( comments_open() || '0' != get_comments_number() )
comments_template( '', true );
?>
<?php endwhile; // end of the loop. ?> <?php endwhile; // end of the loop. ?>

View File

@ -20,7 +20,11 @@ get_header(); ?>
<?php get_template_part( 'content', 'page' ); ?> <?php get_template_part( 'content', 'page' ); ?>
<?php comments_template( '', true ); ?> <?php
// If comments are open or we have at least one comment, load up the comment template
if ( comments_open() || '0' != get_comments_number() )
comments_template( '', true );
?>
<?php endwhile; // end of the loop. ?> <?php endwhile; // end of the loop. ?>