Newer/Older posts links display same posts on every page

I am using a plugin called “Types” to generate custom post types for drink/food recipes. I want to show booth drink and food recipes on the same page. The posts are displaying fine, but for some reason, when you click “newer posts” or “older posts” it will bring you to a new page, but the new page will have the same posts as page 1. Anyone have any ideas? Thanks in advance!

Here’s my loop:

<div class="postContainer">
    <ol class="news postList">
        <?php query_posts( array('post_type' => array( 'recipe', 'drink-recipe' ), 'cat' => array('12','8'), 'showposts' => 5 )); ?>
        <?php if( have_posts() ): ?>
        <?php while( have_posts() ): the_post(); ?>
        <?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ); ?>
        <li class="row">
            <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" style="background-image:url('<?php echo $image[0]; ?>')">
                <div class="seven offset-by-five">
                    <h3><?php the_title(); ?></h3>
                    <h4><?php the_time('F j, Y') ?></h4>
                    <?php echo the_excerpt(); ?>
                    <div href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" class="button">Read more</div>
        <?php endwhile; ?>

<div id="pagenav">
    <span class="newer"><?php previous_posts_link(__('Newer Posts »','blog')) ?></span>
    <span class="older"><?php next_posts_link(__('« Older Posts','blog')) ?></span>

<?php else: ?>

<div id="post404" class="noposts">

    <p><?php _e('None found.','404'); ?></p>


<?php endif; wp_reset_query(); ?>

<?php get_footer(); ?>


If you look here you’ll see that pagination is a caveat of query_posts, and won’t work without the paged variable

The right way to do

$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;

and then add:

'paged' => $paged

to your argument array within query_posts.

Source : Link , Question Author : APAD1 , Answer Author : socki03

Leave a Comment