• Hi there,

    I am having some confusion with a query for showing posts.

    Currently I have this: 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)
  • 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.