WordPress.org

Ready to get started?Download WordPress

Forums

query_posts() is acting up (2 posts)

  1. lobsterman
    Member
    Posted 7 years ago #

    I'm trying to set up my single post page so that the previous and next posts show in the sidebar, here's the code i'm using:

    <?php
    $prev = get_previous_post();
    query_posts("p=$prev->ID&showposts=1");
    ?>
    ... the loop ...

    <?php
    $next = get_next_post();
    query_posts("p=$next->ID&showposts=1");
    ?>
    ... the loop ...

    the first query works fine, the second just shows the same post as the main post on the page. if i reverse them, still it's only the first one that works fine.
    Any ideas?

  2. moshu
    Member
    Posted 7 years ago #

    I am not a coder, so I won't even try to explain to you how to do it :) The only thing I am good at: I can read.
    http://codex.wordpress.org/The_Loop#Multiple_Loops
    All the examples there show different methods how to call another query/Loop... whatever.

Topic Closed

This topic has been closed to new replies.

About this Topic