Why is while()
used instead of say if()
here:
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', 'single' ); ?>
<?php _s_post_nav(); ?>
<?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();
endif;
?>
<?php endwhile; // end of the loop. ?>
So I’ve seen this since forever and I’ve used it too because it’s what WordPress uses by default. However today I’m feeling a bit more curious than usual – why is while used instead of if ? Am I expecting to receive more than a single post in single post view ?
https://github.com/Automattic/_s/blob/master/page.php#L18
https://github.com/Automattic/_s/blob/master/single.php#L13