Skip to content

Instantly share code, notes, and snippets.

@krogsgard
Created February 20, 2012 04:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krogsgard/1867897 to your computer and use it in GitHub Desktop.
Save krogsgard/1867897 to your computer and use it in GitHub Desktop.
The Basic WordPress Loop
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php // You can do stuff here to display aspects of the posts which meet the criteria of the current loop. ?>
<?php endwhile; else: ?>
<p><?php _e('The Loop did not find anything.'); ?></p>
<?php endif; ?>
<?php if ( have_posts() ) {
while ( have_posts() ) {
the_post();
// You can do stuff here to display aspects of the posts which meet the criteria of the current loop.
}
} else { ?>
<p><?php _e('The Loop did not find anything.'); ?></p>
<?php } ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment