WordPress.org

Support

Support » Themes and Templates » Next_Posts_Link not displays same posts (not next posts) when using Offset.

Next_Posts_Link not displays same posts (not next posts) when using Offset.

  • Hi Guys,

    I’m editing the Main Index Template to give my site more of a magazine feel. I have 2 sections on the page that display featured stories and the 3 newest stories, both using the get_posts() query.

    I’ve now laid out the remaining section, which uses the main wordpress loop. Due to the fact that I’ve already displayed 3 of the newest stories I do not want to display them again when the main loop runs, so I’ve been trying to use offset to achieve this.

    The problem is that when I use offset the correct number of posts are skipped, but when I click the Next_Posts_Link the same posts are diplayed again on page 2, which should display the remaining posts.

    I’ve tried the following to resolve this problem:

    1)
    query_posts(‘posts_per_page=6&offset=3’);

    The offset works, but the same four posts are displayed on page 2.

    2)
    <?php
    $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1;
    $args=array(
    ‘offset’=>3,
    ‘posts_per_page’=>6,
    ‘caller_get_posts’=>1,
    ‘paged’=>$paged,
    );
    query_posts($args);
    ?>

    Again, the offset works, but the same four posts are displayed on page 2.

    3) I’ve tried creating a new WP_Query() object and referencing this in the loop, with the same results.

    In all three cases, if I remove the offset parameter, when clicking the Next_Posts_Link the correct posts are displayed… all bar the three that I’m trying to skip.

    If anyone could help, I’d be really grateful.

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Next_Posts_Link not displays same posts (not next posts) when using Offset.’ is closed to new replies.
Skip to toolbar