Title: Query Posts based on Variable Date Range
Last modified: August 20, 2016

---

# Query Posts based on Variable Date Range

 *  [lolroflcopter](https://wordpress.org/support/users/lolroflcopter/)
 * (@lolroflcopter)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/query-posts-based-on-variable-date-range/)
 * Hello. I am attempting to query all posts within a week of the current post.
 * _[[code moderated – please use the pastebin for any code over 10 lines](http://codex.wordpress.org/Forum_Welcome#Posting_Code)]_
 * Everything is functioning as expected, except for the variable $end_date in the
   filter_where function. When I replace the variable with the correct date (the
   same date the variable is returning) the page functions as it should.
 * Why would there not be an issue with the $post_date variable but one with the
   $end date?
 * Thanks.

The topic ‘Query Posts based on Variable Date Range’ is closed to new replies.

## Tags

 * [date](https://wordpress.org/support/topic-tag/date/)
 * [range](https://wordpress.org/support/topic-tag/range/)
 * [template](https://wordpress.org/support/topic-tag/template/)
 * [variable](https://wordpress.org/support/topic-tag/variable/)

 * 0 replies
 * 1 participant
 * Last reply from: [lolroflcopter](https://wordpress.org/support/users/lolroflcopter/)
 * Last activity: [14 years, 4 months ago](https://wordpress.org/support/topic/query-posts-based-on-variable-date-range/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
