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 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(); ?>

share|improve this question

migrated from stackoverflow.com May 3 '12 at 15:08

This question came from our site for professional and enthusiast programmers.

I suggest you read Querying Posts Without query_posts. Using query_posts is not a very good idea. – Hamed Momeni Sep 22 '12 at 17:13

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.

share|improve this answer

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





share|improve this answer

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.