Skip to content

Instantly share code, notes, and snippets.

@mattbrett
Created June 7, 2013 20:53
Show Gist options
  • Save mattbrett/5732351 to your computer and use it in GitHub Desktop.
Save mattbrett/5732351 to your computer and use it in GitHub Desktop.
WordPress: Basic Loop
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', 'index' ); ?>
<?php endwhile; ?>
<?php if ( function_exists('wp_pagenavi') ) : wp_pagenavi(); else : ?>
<!-- pagination -->
<div id="pagination">
<div class="alignleft"><?php previous_posts_link('Previous', 0); ?></div>
<div class="alignright"><?php next_posts_link('Next', 0); ?></div>
</div>
<!-- /pagination -->
<?php endif; ?>
<?php else : ?>
<p><?php _e('Sorry, there are no posts or pages that matched your criteria. Be sure to check your spelling. If all else fails, you can <a href="javascript:history.back()">go back to the page you came from</a>, return to the <a href="' . home_url() . '">homepage</a>, or try searching.','mb'); ?></p>
<?php endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment