Title: query_posts() is acting up
Last modified: August 18, 2016

---

# query_posts() is acting up

 *  [lobsterman](https://wordpress.org/support/users/lobsterman/)
 * (@lobsterman)
 * [19 years, 9 months ago](https://wordpress.org/support/topic/query_posts-is-acting-up/)
 * 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?

Viewing 1 replies (of 1 total)

 *  [moshu](https://wordpress.org/support/users/moshu/)
 * (@moshu)
 * [19 years, 9 months ago](https://wordpress.org/support/topic/query_posts-is-acting-up/#post-428461)
 * 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](http://codex.wordpress.org/The_Loop#Multiple_Loops)
   All the examples there show different methods how to call _another_ query/Loop…
   whatever.

Viewing 1 replies (of 1 total)

The topic ‘query_posts() is acting up’ is closed to new replies.

## Tags

 * [next](https://wordpress.org/support/topic-tag/next/)
 * [prev](https://wordpress.org/support/topic-tag/prev/)
 * [query_posts](https://wordpress.org/support/topic-tag/query_posts/)

 * 1 reply
 * 2 participants
 * Last reply from: [moshu](https://wordpress.org/support/users/moshu/)
 * Last activity: [19 years, 9 months ago](https://wordpress.org/support/topic/query_posts-is-acting-up/#post-428461)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
