WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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(); ?>
share|improve this question
Have you looked over any of the "Related" questions on the right hand side of this page, or searched this website for a solution? What have you tried? – Howdy_McGee Dec 5 '13 at 16:15
Of course you get the same posts, you are running the same query. Search the site for pre_get_posts – s_ha_dum Dec 5 '13 at 16:21
up vote 0 down vote accepted

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.

share|improve this answer
That worked great, thanks! – APAD1 Dec 5 '13 at 16:28
The right way to do it pretty much never involves query_posts at all. – s_ha_dum Dec 5 '13 at 16:58

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.