Title: working navigation with offset in loop
Last modified: August 19, 2016

---

# working navigation with offset in loop

 *  Resolved [Smoothweb](https://wordpress.org/support/users/smoothman/)
 * (@smoothman)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/working-navigation-with-offset-in-loop/)
 * Hello,
 * I am trying to use multiple loops to show the first 5 posts as normal, and only
   show the title for another 15 posts. When clicked on the navigation “page 2” 
   their should be 20 following posts existing from titles.
 * I am seaching and testing for 2 days now and all I test is either using offset(
   to exclude the first posts from a loop) or navigation. I cant get them working
   together….
 * [This posts had a solution, but the code is gone](http://wordpress.org/support/topic/366775?replies=19)
 * [This](http://weblogtoolscollection.com/archives/2008/06/19/how-to-offsets-and-paging/),
   [this](http://forum.go41.de/topic/display-first-post-full-and-following-posts-as-excerpts),
   [this ](http://net.tutsplus.com/tutorials/wordpress/build-a-featured-posts-section-for-wordpress/)&
   [this ](http://max.limpag.com/2006/08/05/how-to-use-wordpress-magazine-news-cms/)
   webpage couldn’t help me (and another 100 websites), mayby you can…
 * Thanx in advance!

Viewing 8 replies - 1 through 8 (of 8 total)

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/working-navigation-with-offset-in-loop/#post-1598532)
 * the idea in the other thread was something like using one loop, a counter, and
   an if statement if it is one of the first five posts on the front page or not:
 *     ```
       <?php
       $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
       query_posts('posts_per_page=20&paged=' . $paged);
       if(have_posts()) :
         $counter = 1;
         while(have_posts()) : the_post();
           if( !is_paged && $counter <= 5 ) :
             /*insert the code to show the full post*/
           else :
             /*insert the code to show title only*/
           endif;
           $counter++;
         endwhile;
         /* insert the code for navigation here */
       else:
         echo 'nothing found';
       endif;
       ?>
       ```
   
 * this particular line
    `if( !is_paged && $counter <= 5 ) :` checks if it is not
   on a paged page, and also one of the first five posts – then shows the full post
   as normal; in any other case (on one of the following pages, or post 6 or higher)–
   show the title only.
 * [http://codex.wordpress.org/Function_Reference/is_paged](http://codex.wordpress.org/Function_Reference/is_paged)
 *  Thread Starter [Smoothweb](https://wordpress.org/support/users/smoothman/)
 * (@smoothman)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/working-navigation-with-offset-in-loop/#post-1598541)
 * Looks solid!
 * How do I insert these post codes?
    The following can’t be good….
 *     ```
       <?php
       $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
       query_posts('posts_per_page=20&paged=' . $paged);
       if(have_posts()) :
         $counter = 1;
         while(have_posts()) : the_post();
           if( !is_paged && $counter <= 5 ) :
   
       	  /*insert the code to show the full post*/
       	  <div class="title"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></div>
       	<?php the_excerpt(); ?>
   
           else :
             /*insert the code to show title only*/
             <div class="title"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></div>
           endif;
           $counter++;
         endwhile;
         /* insert the code for navigation here */
         <div><?php wp_pagenavi(); ?></div>
       else:
         echo 'nothing found';
       endif;
       ?>
       ```
   
 *  Thread Starter [Smoothweb](https://wordpress.org/support/users/smoothman/)
 * (@smoothman)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/working-navigation-with-offset-in-loop/#post-1598567)
 * *bump*
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/working-navigation-with-offset-in-loop/#post-1598583)
 * you need to take care to close the php tags before using html tags and vice-versa.
 *     ```
       <?php
       $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
       query_posts('posts_per_page=20&paged=' . $paged);
       if(have_posts()) :
         $counter = 1;
         while(have_posts()) : the_post();
           if( !is_paged && $counter <= 5 ) :
       	  /*insert the code to show the full post*/
       ?>
       	  <div class="title"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></div>
       	<?php the_excerpt(); ?>
   
       <?php    else :
             /*insert the code to show title only*/
        ?>
          <div class="title"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></div>
        <?php   endif;
           $counter++;
         endwhile;
         /* insert the code for navigation here */
       ?>
         <div><?php wp_pagenavi(); ?></div>
       <?php else:
         echo 'nothing found';
       endif;
       ?>
       ```
   
 *  Thread Starter [Smoothweb](https://wordpress.org/support/users/smoothman/)
 * (@smoothman)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/working-navigation-with-offset-in-loop/#post-1598704)
 * Thnx, there’s a first thing for everything, right
 * The page doesn’t show (ignores) the code for the first five posts …
    It simply
   just uses the <? php else and shows the title for all posts.
 * [See my example](http://www.foodquest.nl/posts.gif)
 * (ps. I have edit “posts_per_page=20” to 5 and “$counter <= 5” to 2 beacause of
   the limit amount of posts I have in the test version of the website.)
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/working-navigation-with-offset-in-loop/#post-1598705)
 * my bad:
 * this line:
 *     ```
       if( !is_paged && $counter <= 5 ) :
       ```
   
 * should be:
 *     ```
       if( !is_paged() && $counter <= 5 ) :
       ```
   
 *  Thread Starter [Smoothweb](https://wordpress.org/support/users/smoothman/)
 * (@smoothman)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/working-navigation-with-offset-in-loop/#post-1598706)
 * THANK YOU so much my friend!
 *  Thread Starter [Smoothweb](https://wordpress.org/support/users/smoothman/)
 * (@smoothman)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/working-navigation-with-offset-in-loop/#post-1598800)
 * Back again. The wordpress site is online, only the loop is not working anymore….
   It is still working under the localhost version (which is exacly the same as 
   the one online).
 * What happens is: The first 5 full posts and the next 15 titles on the first page
   are perfect. When I go to page 2 it shows the loop.php markup instead of the 
   code above (that works in the localhost)
 * Isnt’t that wierd? Do you have any idea?
 * PS. I remembered putting a different category to it instead of cat=1 its cat=
   6, thats all….
    query_posts(‘cat=6&posts_per_page=20&paged=’ . $paged);

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘working navigation with offset in loop’ is closed to new replies.

## Tags

 * [loop](https://wordpress.org/support/topic-tag/loop/)
 * [navigation](https://wordpress.org/support/topic-tag/navigation/)
 * [offset](https://wordpress.org/support/topic-tag/offset/)

 * 8 replies
 * 2 participants
 * Last reply from: [Smoothweb](https://wordpress.org/support/users/smoothman/)
 * Last activity: [15 years, 9 months ago](https://wordpress.org/support/topic/working-navigation-with-offset-in-loop/#post-1598800)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
