WordPress Page Template not using pagination, work display the next and previous links to go back and forth between latest and oldest posts, along with that putting /page/2 just displays the same post too.
Here’s the code:-
<div id="homeContentLeft">
<h1>Latest Posts</h1>
<?php
rewind_posts();
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args= array(
'posts_per_page' => 1,
'cat' => 1,
'paged' => $paged
);
query_posts($args);
?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<div class="entry">
<a href="<?php the_permalink() ?>">
<div id="homeNewsThumbnail">
<?php
if ( has_post_thumbnail() ) {
the_post_thumbnail('thumbnail');
}
?>
<div id="homeNewsBoxDate">
<large><?php the_time('j') ?></large>
<small><?php the_time('M') ?></small>
</div>
</div>
</a>
<div id="homeNewsBox">
<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
<?php echo substr(get_the_excerpt(), 0,320); ?>...
<readmore> <a href="<?php the_permalink() ?>">> Read More</a></readmore>
</div>
<div style="clear:both"></div>
</div>
<?php endwhile; ?>
<?php wp_reset_query();?>
<div class="alignleft"><?php next_posts_link('« Older Entries') ?></div>
<div class="alignright"><?php previous_posts_link('Newer Entries »') ?></div>
<?php else : ?>
<h2>Not Found</h2>
<div class="inner-entry">
<p>Sorry, but you are looking for something that isn't here.</p>
</div>
<?php endif; ?>
</div>
Any help would be greatly appreciated!
Thank you
~ Kind Regards
It looks like your
rewind_posts()
function is resetting the loop. So yourget_query_var()
call is always pulling from the beginning. Try placingrewind_posts()
after the$paged = get_query_var(...
Hope that helps