Loop posts between from current post date and a set date?
-
I’m trying to make a loop that displays 5 posts between two dates. This shouldn’t be hard but one of the dates is the date of the current post and is therefore a variable…
This is what I’ve come up with but it doesn’t work. No errors but just shows all posts.
function filter_where($where = '') { $where .= ' AND post_date >= "2000-01-01" AND post_date <= "' . $date .'"'; return $where; } add_filter('posts_where', 'filter_where'); query_posts('showposts=5');
The $date is retrieved from another loop like this:
$date = the_date('Y-m-d');
and I’ve tried to define $date manually but it won’t work:
$date = "2010-01-01";
Would be grateful for any ideas!
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Loop posts between from current post date and a set date?’ is closed to new replies.