Title: Insert Variable into Query Posts for Post ID?
Last modified: August 18, 2016

---

# Insert Variable into Query Posts for Post ID?

 *  [obeattie](https://wordpress.org/support/users/obeattie/)
 * (@obeattie)
 * [19 years, 8 months ago](https://wordpress.org/support/topic/insert-variable-into-query-posts-for-post-id/)
 * Hey All,
 * I am trying to build a query which results in one post being retrieved from a
   certain range if IDs. I have tried this:
 * <?php query_posts(“p=’.rand(50, 70).’&showposts=1”); ?>
 * But it doesn’t seem to work. Could someone possibly point me in the right direction?
 * Many Thanks,
    Oliver

Viewing 1 replies (of 1 total)

 *  Thread Starter [obeattie](https://wordpress.org/support/users/obeattie/)
 * (@obeattie)
 * [19 years, 8 months ago](https://wordpress.org/support/topic/insert-variable-into-query-posts-for-post-id/#post-452945)
 * Bump

Viewing 1 replies (of 1 total)

The topic ‘Insert Variable into Query Posts for Post ID?’ is closed to new replies.

## Tags

 * [Howto](https://wordpress.org/support/topic-tag/howto/)
 * [query_posts](https://wordpress.org/support/topic-tag/query_posts/)
 * [variable](https://wordpress.org/support/topic-tag/variable/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 1 participant
 * Last reply from: [obeattie](https://wordpress.org/support/users/obeattie/)
 * Last activity: [19 years, 8 months ago](https://wordpress.org/support/topic/insert-variable-into-query-posts-for-post-id/#post-452945)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
