I have a custom taxonomy for a group of posts, and I also have a need to show these posts on a custom page template. I want to show one post at a time, with pagination, so that the user can click through them like a slide show.

My template correctly grabs the right category and display one (the first) post, but when I try to click through the pagination, it sends me to the archives for the next post. I want to click "next" and be taken to the next post within the same page template.

I've working with this solution, but I can't get it to work.

Here's my code, as it is...

<body <?php body_class(); ?>>
<div id="full-page">
    <div id="wrap">
        <div id="full-main-col">
            <a href="#" id="share" rel="prettySociable" title="Drag to Share"><img src="<?php echo get_template_directory_uri(); ?>/img/share.png" alt="" /></a>

            <?php if (have_posts()) :
                            while (have_posts()) :
                            the_post(); ?>

                                <div id="page-head">
                                    <?php the_title('<h1>', '</h1>');
                                    if (function_exists('dimox_breadcrumbs')) dimox_breadcrumbs(); ?>

                           <?php endwhile;
                        endif; ?>
            <?php include( TEMPLATEPATH . '/sidebar-right.php' ); ?>

              query_posts( array( 'post_type' => 'fieldtrips', 'fieldtripcategory' => 'elementary-school-aquifer', 'order' => 'ASC', 'posts_per_page' => 1 ) );
              if ( have_posts() ) : while ( have_posts() ) : the_post();

              <h3><?php the_title(); ?></h3>
              <?php the_content(); ?>

              <?php previous_post('&laquo; &laquo; %', '', 'yes'); ?> | <?php next_post('% &raquo; &raquo; ', '', 'yes'); ?>

            <?php endwhile; endif; wp_reset_query(); ?>


2 Answers 2


query_posts = _your_doing_it_wrong

as soon as you throw in that nasty query_posts you are killing off all the global variables and your paging will not work.


 query_posts( array( 'post_type' => 'fieldtrips', 'fieldtripcategory' => 'elementary-school-aquifer', 'order' => 'ASC', 'posts_per_page' => 1 ) );
              if ( have_posts() ) : while ( have_posts() ) : the_post();


   $my_query = new WP_Query( array( 'post_type' => 'fieldtrips',
                                    'fieldtripcategory' => 'elementary-school-aquifer',
                                     'order' => 'ASC',
                                     'posts_per_page' => 1
                  if ( $my_query->have_posts() ) : while ( $my_query->have_posts() ) : $my_query->the_post();

Also remove the wp_reset_query.


previous_posts() and next_posts() are deprecated. Try these instead:





Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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