Display published posts between two dates

Adding this snippet to your wordpress theme will enable you to display published posts between two dates. You could place this great little snippet within your sidebar or create a custom template to display last years posts.

 

 

<?php
function filter_where($where = '') {
$where .= " AND post_date >= '1980-05-11' AND post_date <= '2011-05-11'";
return $where;
}
add_filter('posts_where', 'filter_where');
query_posts($query_string);
while (have_posts()) :
the_post();
the_content();
endwhile;
?>

Be Sociable, Share!

Leave a comment