Skip to content

Instantly share code, notes, and snippets.

@stompweb
Created June 28, 2012 19:05
Show Gist options
  • Save stompweb/3013240 to your computer and use it in GitHub Desktop.
Save stompweb/3013240 to your computer and use it in GitHub Desktop.
WordPress Pagination
<div id="content">
<h1>Ice Creams</h1>
<?php
$paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;
$args = array(
'posts_per_page' => 5,
'paged' => $paged
);
$wp_query = new WP_Query( $args );
if ( have_posts() ) : while ( $wp_query->have_posts() ) : $wp_query->the_post();?>
<div class="icecream">
<h3><?php the_title(); ?></h3>
<?php the_excerpt(); ?>
<a href="<?php the_permanlink(); ?>" class="more">Read More</a>
</div>
<?php endwhile; ?>
<div id="pagination">
<div id="next-page">
<?php next_posts_link('&laquo; Older Entries') ?>
</div>
<div id="previous-page">
<?php previous_posts_link('Newer Entries &raquo;') ?>
</div>
</div>
<?php endif; ?>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment