Display published posts between two dates

Sucuri Review - scan for malware

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.

  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');
while (have_posts()) :

Comments  Leave a Reply

  1. Is it possible to use variables as dates?

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!