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 15 replies - 1 through 15 (of 21 total)

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

 *  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/#post-1521841)
 * query_posts(‘posts_per_page=11’); in this line i added 11 becouse when i filter
   these from first loop only displaying 5
    Well just to save time it might be helpful…
   🙂
 *  [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/#post-1521843)
 * searching for ‘query_posts paged’ should give you some info
 *  [jimmyt1988](https://wordpress.org/support/users/jimmyt1988/)
 * (@jimmyt1988)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/previous_posts_link-next_posts_link-problem/#post-1521849)
 * Alchy. I suggest you search for it. I have just read for 25 minutes trying to
   get that to work on my WordPress, and it has not been constructive for my learning,
   or me… hehehhe. *headache*
 * Could me and above person have a little more information?
 * Thanks though!
 *  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/#post-1521860)
 * I have reached 4 hours 😀 still no clue
    but I found this site, but i dont get
   it 😀
 * [http://stylizedweb.com/2008/08/13/query_posts-pagination-problem/](http://stylizedweb.com/2008/08/13/query_posts-pagination-problem/)
 *  [jimmyt1988](https://wordpress.org/support/users/jimmyt1988/)
 * (@jimmyt1988)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/previous_posts_link-next_posts_link-problem/#post-1521865)
 * Don’t worry about that site.
 * The default set up on the default theme is:
 *     ```
       <?php if (have_posts()) : ?>
   
       	<?php while (have_posts()) : the_post(); ?>
   
       		<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
       			<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
       			<small><?php the_time('F jS, Y') ?> <!-- by <?php the_author() ?> --></small>
   
       			<div class="entry">
       				<?php the_content('Read the rest of this entry &raquo;'); ?>
       			</div>
   
       			<p class="postmetadata"><?php the_tags('Tags: ', ', ', '<br />'); ?> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?>  <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p>
       		</div>
   
       	<?php endwhile; ?>
   
       	<div class="navigation">
       		<div class="alignleft"><?php next_posts_link('&laquo; Older Entries') ?></div>
       		<div class="alignright"><?php previous_posts_link('Newer Entries &raquo;') ?></div>
       	</div>
   
       <?php else : ?>
   
       	<h2 class="center">Not Found</h2>
       	<p class="center">Sorry, but you are looking for something that isn't here.</p>
       	<?php get_search_form(); ?>
   
       <?php endif; ?>
   
       </div>
       ```
   
 * Try that, I’ll tell you if it works on mine.
 *  [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/#post-1521867)
 * [@harrismc](https://wordpress.org/support/users/harrismc/)
    the link you found
   is in my opinion the best article on the topic; the codex is unfortunately rahter
   short on the subject of pagination with custom queries.
 * i think your added trouble is how to define what you are trying to paginate, 
   i.e. what the display of page2 should be.
 * if you could clarify, what you want to show on page2, page3 etc, then it might
   be easier to help you past the link you’ve already found.
 * if you are using the second loop as the base for the paginatioin, you also might
   need to add a ‘wp_reset_query();’ before the second loop.
 * try to change this:
 *     ```
       <?php if (have_posts()) : ?>
       <?php rewind_posts(); ?>
       <?php 
   
       query_posts('posts_per_page=11');
   
       while (have_posts()) : the_post(); update_post_caches($posts);
       ```
   
 * into this:
 *     ```
       <?php if (have_posts()) : ?>
       <?php rewind_posts(); ?>
       <?php
       wp_reset_query();
       $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
       query_posts('posts_per_page=11&paged='.$paged);
   
       while (have_posts()) : the_post(); update_post_caches($posts);
       ```
   
 * this will obviously give you 11 post on the page2, etc.
 * to get rid of the three posts from the first query you may need to use a conditional
   statement for it; something like
    `<?php if(!is_paged()) { */first loop here*/}?
   >`.
 * [http://codex.wordpress.org/Conditional_Tags&usg=ALkJrhihZeAd-cOg_CRVKm5kFg6YR_agEA#A_Paged_Page](http://codex.wordpress.org/Conditional_Tags&usg=ALkJrhihZeAd-cOg_CRVKm5kFg6YR_agEA#A_Paged_Page)
 *  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/#post-1521885)
 * Thanks
 *     ```
       <?php if (have_posts()) : ?>
       <?php rewind_posts(); ?>
       <?php
       wp_reset_query();
       $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
       query_posts('posts_per_page=11&paged='.$paged);
   
       while (have_posts()) : the_post(); update_post_caches($posts);
       ```
   
 * This worked for me I got just what i was searching for.
    Thanks again
 *  [Shane G.](https://wordpress.org/support/users/shane-g-1/)
 * (@shane-g-1)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/previous_posts_link-next_posts_link-problem/#post-1521910)
 * Hi,
 * Check with this page navigation plugin:
 * [http://wordpress.org/extend/plugins/wordpress-navigation-list-plugin-navt/](http://wordpress.org/extend/plugins/wordpress-navigation-list-plugin-navt/)
 * Thanks,
 * Shane G.
 *  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/#post-1521966)
 * Navigation works fine, so here’s what I wanted to make it..
    At first page, first
   loop displays 3 latest post, and other 8 are displayed in short way, I have manage
   to do that, but my client wants that when he press next in page navigation , 
   that those 3 latest don’t be displayed, only those short one’s. And what i got
   now is almost done , except I dont know how to remove those 3 “sticky” posts 
   in next page… Any ideas ?
 *  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/#post-1521968)
 * can I use is_home() or is_front_page() ?
 *  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/#post-1521992)
 *  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/#post-1521993)
 * [http://www.chrisbrogan.com/page/2/](http://www.chrisbrogan.com/page/2/)
 * To look like this
 *  [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/#post-1522029)
 * did you try what i suggested in my earlier reply:
 * > to get rid of the three posts from the first query you may need to use a conditional
   > statement for it; something like
   > `<?php if(!is_paged()) { */first loop here*/ } ?>` .
   > [http://codex.wordpress.org/Conditional_Tags&usg=ALkJrhihZeAd-cOg_CRVKm5kFg6YR_agEA#A_Paged_Page](http://codex.wordpress.org/Conditional_Tags&usg=ALkJrhihZeAd-cOg_CRVKm5kFg6YR_agEA#A_Paged_Page)
 *  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/#post-1522041)
 * Yes i tried it works but over the header of those mini posts im getting this 
   error
    [function.in-array]: Wrong datatype for second argument in /home/droren/
   drorengel/blog/wp-content/themes/hp-blog/index.php on line 41
 *  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/#post-1522042)
 * if ( !in_array( $post->ID, $do_not_duplicate ) ):
    This line i guess

Viewing 15 replies - 1 through 15 (of 21 total)

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

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
