Title: Query Posts question
Last modified: August 19, 2016

---

# Query Posts question

 *  [karlb](https://wordpress.org/support/users/karlb/)
 * (@karlb)
 * [16 years, 6 months ago](https://wordpress.org/support/topic/query-posts-question-1/)
 * Hi there,
 * I am having some confusion with a query for showing posts.
 * Currently I have this: [http://paste-it.net/public/lbb7793/](http://paste-it.net/public/lbb7793/)
 * which shows latest post, then 3 recent and then a list of the rest.
 * Now what I want to show 5 latest posts, then 3, then the list but I am getting
   confused. The code below – I believe – controls the latest post, but what do 
   I need to change to show 5 latest posts?
 * ‘ <?php
    $postCount = 0; query_posts( ‘showposts=900&post_per_page=-1&cat=’ .
   get_query_var(‘cat’) ); while (have_posts()) { the_post(); if( $postcount == 
   0 ) { ?>
 *  <?php
    //This grabs the latest excerpt if (isset($values[0])) { ?> ‘
 * Any help greatly appreciated.
 * Cheers,
    Karl

Viewing 1 replies (of 1 total)

 *  [s_ha_dum](https://wordpress.org/support/users/apljdi/)
 * (@apljdi)
 * [16 years, 6 months ago](https://wordpress.org/support/topic/query-posts-question-1/#post-1299325)
 * What you have is:
 *     ```
       while (have_posts()) { the_post();
         if( $postcount == 0 ) { ?>
           <!-- code to display the first post -->
         <?php } elseif( $postcount > 0 && $postcount <= 3 ) { ?>
           <!-- code to display posts 2,3, and 4-->
         <?php } else {
           <!-- code for everything else -->
         }
       }
       ```
   
 * Keeping the same basic structure that you’ve already got, what you probably want
   is:
 *     ```
       while (have_posts()) { the_post();
         if( $postcount <= 4 ) { ?>
           <!-- code to display the first five posts -->
         <?php } elseif( $postcount > 4 && $postcount <= 7 ) { ?>
           <!-- code to display posts 5,6, and 7 -->
         <?php } else {
           <!-- code for everything else -->
         }
       }
       ```
   
 * Assuming I haven’t screwed up some detail…

Viewing 1 replies (of 1 total)

The topic ‘Query Posts question’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [s_ha_dum](https://wordpress.org/support/users/apljdi/)
 * Last activity: [16 years, 6 months ago](https://wordpress.org/support/topic/query-posts-question-1/#post-1299325)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
