I just want to List the posts published between two particular dates
I found a solution Here http://www.wprecipes.com/wordpress-loop-get-posts-published-between-two-particular-dates
and my code is Here, unfortunately This is not working !!
<?php
function filter_where($where = '') {
$where .= " AND post_date >= '2012-05-09' AND post_date <= '2012-05-11'";
//$where .= " AND post_date > '" . date('Y-m-d', strtotime('-30 days')) . "'";
return $where;
}
add_filter('posts_where', 'filter_where');
query_posts($query_string);
?>
<?php while (have_posts()) : the_post(); ?>
<h1><?php the_title(); ?></h1>
<?php endwhile; ?>
First you shouldn’t be using
query_posts()as it will destroy globals and mess up conditionals etc…You didn’t mention where this code is running. If it is on a page template for instance you will not get any posts because when pass $query_string into your query you are using the global $wp_query object and it will only query for page post_types.
I tested your code using new WP_Query instead of query_posts and it worked fine.