Bruce Alrighty
Member
Posted 3 years ago #
I have a loop in which I want to display 1 post on the page and then have next and previous links to the next page of 1 post and so on.
For some reason the post on the 1st page is the same as the one on the 2nd page. So the 2nd post does not appear. Can anyone explain why?
Below is my loop:
<ul class="gallery clearfix">
<?php query_posts('category_name=events&posts_per_page=1'); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); $do_not_duplicate = $post->ID; ?>
<?php the_content(); ?>
<?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>
<?php posts_nav_link(); ?>
what happens if you set your Permalinks back to default?
Bruce Alrighty
Member
Posted 3 years ago #
I reset the permalinks and no change.
Bruce Alrighty
Member
Posted 3 years ago #
So backing up a step, why not use a "normal" Loop? (see The_Loop for docs) Then just set your options to show one page at a time?
Bruce Alrighty
Member
Posted 3 years ago #
I changed the settings in the admin to 1 and removed the query, but now no posts are displayed.
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>
Instead of this:
<?php query_posts('category_name=events&posts_per_page=1'); ?>
Use this:
<?php query_posts($query_string.'&category_name=events&posts_per_page=1'); ?>
Bruce Alrighty
Member
Posted 3 years ago #
@Otto42 I tried it and still no posts are displayed.