This is working for me on a single page using a template. Just be sure to set next_posts_link( 'Older Entries »', $query$the_query->max_num_pages );
.
// set the "paged" parameter (use 'page' if the query is on a static front page)
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : '1';
$args = array (
'nopaging' => false,
'paged' => $paged,
'posts_per_page' => '5',
'post_type' => 'post',
);
// The Query
$query = new WP_Query( $args );
// The Loop
if ( $query->have_posts() ) {
previous_posts_link( '« Newer Entries' );
while ( $query->have_posts() ) {
$query->the_post();
echo '<div class="news-item">';
// post stuff here
echo '<h1 class="page-title screen-reader-text">' . the_title() . '</h1>';
echo '</div>';
}
next_posts_link( 'Older Entries »', $query->max_num_pages );
} else {
// no posts found
echo '<h1 class="page-title screen-reader-text">No Posts Found</h1>';
}
// Restore original Post Data
wp_reset_postdata();