Query_posts() showposts - don't show first post (6 posts)

  1. zeleke
    Posted 7 years ago #

    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.

  2. Mark / t31os

    Posted 7 years ago #

    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....

  3. zeleke
    Posted 7 years ago #

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

    The first loop styles the post differently.

  4. Mark / t31os

    Posted 7 years ago #

    For starters...

    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

  5. zeleke
    Posted 7 years ago #

    Thanks, t31os_.

    The offset parameter fixed the problem perfectly.

  6. Mark / t31os

    Posted 7 years ago #

    Good stuff, post back if you get stuck... :)

Topic Closed

This topic has been closed to new replies.

About this Topic