WordPress.org

Support

Support » Themes and Templates » Query_posts() showposts – don’t show first post

Query_posts() showposts – don’t show first post

  • I’m using the query_posts() function with the loop on the homepage.

    I have a separate function showing the latest post using a different loop. There’s the “Latest Post” loop. Then beneath that’s the “Rest of the latest posts” loop. But the first one in the latter loop shows the latest post.

    So I want to know how to subtract the first post from my query_posts() function.

    Thanks in advance.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Why use 2 loops?…

    If you’d like to share what you have so far i’m sure we can trim it all down into one query for you….

    <?php
    $latestPost = new WP_Query();
    $latestPost->query('showposts=1');
    while ($latestPost->have_posts()) : $latestPost->the_post();
    ?>
    ...
    <?php endwhile; ?>
    
    <?php
    $page = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts("paged=$page");
    while (have_posts()) : the_post();
    ?>
    ...
    <?php endwhile(); ?>

    The first loop styles the post differently.

    For starters…
    http://codex.wordpress.org/Template_Tags/query_posts#Offset_Parameter

    Should give you what you need to offset the posts…

    Is that first query inside any conditions?….

    You should be able to refine that into one query depending on the code you’ve left out from the above… (need to see more).. 🙂

    You’d only need to count the posts… $x=1

    Then if($x == 1) { first post } else { other posts }… etc.. you get the point i’m sure (or hope?)… lol

    Thanks, t31os_.

    The offset parameter fixed the problem perfectly.

    Good stuff, post back if you get stuck… 🙂

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Query_posts() showposts – don’t show first post’ is closed to new replies.