JackDaviesWork
7/21/2017 - 11:00 AM

Get Posts Published Between Two Dates The loop and the query_posts() WordPress function allow you to easily retrieve a list of posts publis

Get Posts Published Between Two Dates

The loop and the query_posts() WordPress function allow you to easily retrieve a list of posts published in a specific week or month. Unfortunately, getting posts published between, for example, March 17 and May 3 isn’t that easy. Let’s solve this problem.

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

?>