I'm trying to create a paginated list of posts, and have used the Codex to write some code but I appear to be doing something wrong.
These are my wp_query
args
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
$the_query = new WP_Query(
array
(
'posts_per_page' => 5,
'post_type' => 'post',
'paged' => $paged
)
);
The content of $paged
does output as 1
which would be expected
I've added next_posts_link
to my if
statement but they don't show.
if ( $the_query->have_posts() ) {
previous_posts_link( '« Newer Entries' );
while ( $the_query->have_posts() ) {
$the_query->the_post();
echo '<div class="news-item">';
// post stuff here
echo '</div>';
}
next_posts_link( 'Older Entries »', 0 );
}
EDIT
The page on which this shows is not a front page, but is a static page I created. I created page-news.php
template and then created a page called 'News' and that it where this code resides. Could that be the reason?