Title: previous_posts_link  next_posts_link problem
Last modified: August 19, 2016

---

# previous_posts_link next_posts_link problem

 *  Resolved [harrismc](https://wordpress.org/support/users/harrismc/)
 * (@harrismc)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/previous_posts_link-next_posts_link-problem/)
 *     ```
       <?php get_header(); ?>
   
       <div class="maincontent">
       		<div class="contentleft">
   
       			<?php if (have_posts()) : ?>
       <?php query_posts('posts_per_page=3');
       $do_not_duplicate = array();
       while (have_posts()) : the_post();
       $do_not_duplicate[] = $post->ID;
       ?>
   
       			<div class="post">
       				<div class="posttitle"><h1><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h1></div>
       				<div class="datebox"><p><span><?php the_time('F j, Y') ?></span> | <?php comments_popup_link('No Comments', '1 Comments', '% Comments'); ?></p></div>
       				<div class="postcontent">
       					<?php the_content('Read the rest of this entry &raquo;'); ?>
       					<iframe src="http://www.facebook.com/plugins/like.php?href=<?php echo urlencode(get_permalink($post->ID)); ?>&layout=standard&show-faces=true&width=500&action=like&colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:500px; height:60px"></iframe>
       					<div class="commentslink"><p><?php comments_popup_link('No Comments', '1 Comments', '% Comments'); ?> | <a href="<?php the_permalink() ?>">Leave a comment</a></p></div>
   
       					<div class="tagbox">
       						<p>Tagged As | <?php the_tags(__(''), ', ', ''); ?></p>
       					</div>
       				</div>
       			</div>
       			<?php endwhile; ?>
       			<?php else : ?>
       			<h2 class="center">Not Found</h2>
       			<p class="center">Sorry, but you are looking for something that isn't here.</p>
       		   <?php endif; ?>
   
       <div id="bottomposts">
        <?php if (have_posts()) : ?>
       <?php rewind_posts(); ?>
       <?php 
   
       query_posts('posts_per_page=11');
   
       while (have_posts()) : the_post(); update_post_caches($posts);
       if ( !in_array( $post->ID, $do_not_duplicate ) ):
       ?>
       <div class="postovi">
        <h2><a href="<?php the_permalink(); ?>" id="post-<?php the_ID(); ?>"><?php the_title(); ?></a></h2>
       <?php echo excerpt(55); ?><p></p>
       <a href="<?php the_permalink(); ?>" id="post-<?php the_ID(); ?>">Read more...</a>
       </div>
       <?php endif; ?>
       <?php endwhile; ?>
       			<?php else : ?>
       			<h2 class="center">Not Found</h2>
       			<p class="center">Sorry, but you are looking for something that isn't here.</p>
       		   <?php endif; ?>
       </div>
   
       <div class="pagination">
       				<div class="previous"><?php previous_posts_link('Previous Entries') ?></div>
       				<div class="next"><?php next_posts_link('Next Entries') ?></div>
       			</div>
       		</div>
       		<div class="contentright">
       			<?php get_sidebar(); ?>
       		</div>
       	</div>
   
       <?php get_footer(); ?>
       ```
   
 * I am having problem with navigation, i use 2 loops in 1st i display 3 recent 
   posts , and in the next one i display 8 short text posts
    but my page navigation
   doesnt work, allways showing same posts

Viewing 6 replies - 16 through 21 (of 21 total)

[←](https://wordpress.org/support/topic/previous_posts_link-next_posts_link-problem/?output_format=md)
[1](https://wordpress.org/support/topic/previous_posts_link-next_posts_link-problem/?output_format=md)
2

 *  Thread Starter [harrismc](https://wordpress.org/support/users/harrismc/)
 * (@harrismc)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/previous_posts_link-next_posts_link-problem/page/2/#post-1522044)
 * I fixed this, i had to create array outside of first loop , that was mistake,
   Thanks alchymyth for help
 *  [triplebull](https://wordpress.org/support/users/triplebull/)
 * (@triplebull)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/previous_posts_link-next_posts_link-problem/page/2/#post-1522143)
 * This was really helpfull for me. But in my case I am trying to renew even the
   first three posts. Is there any way to do that?
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/previous_posts_link-next_posts_link-problem/page/2/#post-1522144)
 * [@triplebull](https://wordpress.org/support/users/triplebull/)
 * are these three first posts some sort of ‘featured’?
 * could you paste the code of your file (index.php?) into a [http://wordpress.pastebin.com/](http://wordpress.pastebin.com/)
   as a starting point for further suggestions?
 * and a link to your site?
 * or even better, start a new thread with your question?
 *  [triplebull](https://wordpress.org/support/users/triplebull/)
 * (@triplebull)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/previous_posts_link-next_posts_link-problem/page/2/#post-1522145)
 * Hi alchymyth, thanks so far. There shouldn’t be anything like featured. I just
   want to separate two kinds of posts from each other. Here’s the link:
 * [http://wordpress.planetfreu.de/category/allgemein/](http://wordpress.planetfreu.de/category/allgemein/)
 * and here the code:
 * 1. This switches between Category and Subcategory, works:
 *     ```
       <?php get_header(); ?>
       <?php genesis_before_content_sidebar_wrap(); ?>
       <div id="content-sidebar-wrap">
   
       <?php genesis_before_loop(); ?>
   
       <?php genesis_before_content(); ?>
         <div id="content" class="hfeed">
           <h1 class="cat-title">News im Bereich - <?php single_cat_title(); ?></h1>
           <?php if (is_category()) {
           $this_category = get_category($cat);
           if (get_category_children($this_category->cat_ID) != "") {
           // This is the Template for Category level 1
           include(CHILD_DIR.'/maincategory.php');
           }
           else	{
           // This is the Template for Category level 2
           include(CHILD_DIR.'/subcategory.php');
           }
   
           } ?>
         </div><!-- end #content -->
       <?php include(CHILD_DIR.'/sidebar-category.php'); ?>
   
       </div><!-- end #content-sidebar-wrap -->
       <?php genesis_after_content_sidebar_wrap(); ?>
   
       <?php get_footer(); ?>
       ```
   
 * 2. This is the subcategory. There should be 2 – 3 Items, each with 3 or 4 Post
   excerpts. Right now it doesn’t work because some content is duplicate at the 
   second page.
 *     ```
       <?php if (have_posts()) : ?>
       <?php rewind_posts(); ?>
       <?php
       wp_reset_query();
       $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
       query_posts('cat='.$cat.'&orderby=date&order=DESC&posts_per_page=3&paged='.$paged);
       while (have_posts()) : the_post(); update_post_caches($posts);
       $do_not_duplicate[] = $post->ID;
       ?>
       <div <?php post_class(); ?>>
         <div class="entry-content first">
           <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail( 'mega' ); ?></a>
           <?php genesis_post_title(); ?>
           <?php wpe_excerpt('wpe_excerptlenght_teaser', 'wpe_excerptmore'); ?>
         </div><!-- end .entry-content -->
       </div>
       <?php endwhile; else: ?>
       <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
       <?php endif; ?><!-- ... end of First Teasers -->
       <div id="bottomposts">
        <?php if (have_posts()) : ?>
       <?php rewind_posts(); ?>
       <?php 
   
       query_posts('cat='.$cat.'&orderby=date&order=DESC&posts_per_page=5');
   
       while (have_posts()) : the_post(); update_post_caches($posts);
       if ( !in_array( $post->ID, $do_not_duplicate ) ):
       ?>
       <div class="postovi">
        <h2><a href="<?php the_permalink(); ?>" id="post-<?php the_ID(); ?>"><?php the_title(); ?></a></h2>
       <?php wpe_excerpt('wpe_excerptlenght_short', 'wpe_excerptmore'); ?><p></p>
       <a href="<?php the_permalink(); ?>" id="post-<?php the_ID(); ?>">Read more...</a>
       </div>
       <?php endif; ?>
       <?php endwhile; ?>
       <?php else : ?>
       <h2 class="center">Not Found</h2>
       <p class="center">Sorry, but you are looking for something that isn't here.</p>
       <?php endif; ?>
       </div>
   
       <div class="pagination">
         <div class="previous"><?php previous_posts_link('Previous Entries') ?></div>
         <div class="next"><?php next_posts_link('Next Entries') ?></div>
       </div>
       ```
   
 * Thanks a lot in advance …
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/previous_posts_link-next_posts_link-problem/page/2/#post-1522146)
 * puzzling is that the first click on ‘next posts’ works as expected,
    showing 
   the right posts, excluding the right ones, etc.; and then the second click (to/
   page/3/) gets the 404 error.
 * unfortunately, i don’t have any ideas how to change this.
 * is there a difference how the categories are linked to these posts – in particular
   is the ‘6. artikel’ different in any way to ‘7. artikel’ and above?
 * and obviously, the question is why do you want to show posts of the same category
   in two different ways?
    it makes kind of sense on the first page (showing the
   three latest in detail, and the following just as excerpts), but becomes kind
   of useless on the second page and further.
 *  [triplebull](https://wordpress.org/support/users/triplebull/)
 * (@triplebull)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/previous_posts_link-next_posts_link-problem/page/2/#post-1522147)
 * Hi and thanks for your support. I tried a different approach and it works well(
   [http://wordpress.planetfreu.de/category/allgemein/](http://wordpress.planetfreu.de/category/allgemein/)).
   If anyone is interested in putting different appearances to excerpt on the category
   page – this works:
 *     ```
       <?php if (have_posts()) : ?>
       <?php $count = 0; ?>
       <?php while (have_posts()) : the_post(); ?>
       <?php $count++; ?>
         <?php if ($count <= 3) : ?>
         				<div <?php post_class(); ?>>
                   <div class="entry-content first">
                     <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail( 'mega' ); ?></a>
                     <?php genesis_post_title(); ?>
                     <?php wpe_excerpt('wpe_excerptlenght_teaser', 'wpe_excerptmore'); ?>
                   </div><!-- end .entry-content -->
                 </div>
          <?php elseif ($count == 4) : ?>
          <div id="featured-bottom">
          <h4 class="widgettitle">weitere News</h4>
          <?php elseif ($count <= 7) : ?>
          				<div <?php post_class(); ?>>
                   <div class="entry-content second">
                     <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail( 'large' ); ?></a>
                     <?php genesis_post_title(); ?>
                     <?php wpe_excerpt('wpe_excerptlenght_short', 'wpe_excerptmore'); ?>
                   </div><!-- end .entry-content -->
                 </div>
          <?php elseif ($count == 8) : ?>
          </div><div class="clear"></div>
          <?php else : ?>
                 <div <?php post_class(); ?>>
                   <div class="entry-content third">
                     <?php genesis_post_title(); ?>
                     <?php wpe_excerpt('wpe_excerptlenght_mini', 'wpe_excerplink'); ?>
                   </div><!-- end .entry-content -->
                 </div>
         <?php endif; ?>
       <?php endwhile; ?>
       <?php endif; ?>
       <?php if(is_single()) { // single-view navigation ?>
       	<?php $posts = query_posts($query_string); if (have_posts()) : while (have_posts()) : the_post(); ?>
       		<?php previous_post_link(); ?> | <?php next_post_link(); ?>
       	<?php endwhile; endif; ?>
       <?php } else { // archive view navigation ?>
       		<?php posts_nav_link(); ?>
       <?php } ?>
       ```
   

Viewing 6 replies - 16 through 21 (of 21 total)

[←](https://wordpress.org/support/topic/previous_posts_link-next_posts_link-problem/?output_format=md)
[1](https://wordpress.org/support/topic/previous_posts_link-next_posts_link-problem/?output_format=md)
2

The topic ‘previous_posts_link next_posts_link problem’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 21 replies
 * 5 participants
 * Last reply from: [triplebull](https://wordpress.org/support/users/triplebull/)
 * Last activity: [15 years, 11 months ago](https://wordpress.org/support/topic/previous_posts_link-next_posts_link-problem/page/2/#post-1522147)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
