Categories
WordPress Templates

About The Loop

The first three lines set up the logic:

<?php if ( have_posts() ) : ?>

<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>

Other themes will express this as a single line:

<?php if ( have_posts() ) : while ( have_posts()): the_post(); ?>

Regardless of these phrasing differences, what’s going on here is that WordPress is checking to see if there are any posts. If there are, it will display them, sequentially. In line 32 we see

<?php endwhile; ?>

Anything that happens between the while and the endwhile will be output to the page.

Try it. At line 23, add in the following HTML

<h1>I do not appreciate the music or hairstyles of Nickelback.</h1>

Now go to the front page of your site:

Screen Shot 2013-07-15 at 7.57.46 PM