Title: [plugin Batch Categories] Query posts on Date
Last modified: August 20, 2016

---

# [plugin Batch Categories] Query posts on Date

 *  Resolved [cstoltenkamp](https://wordpress.org/support/users/cstoltenkamp/)
 * (@cstoltenkamp)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/query-posts-on-date/)
 * Hello,
 * I rewrite Rob Millers Batch Post Category Move/Removed plugin and like to restict
   post-results to a specific date / date range
 * WordPress construct a query string like followed,
    This is the string $q for 
   $query->query($q); “paged=1&posts_per_page=15&orderby=post_date&order=desc&post_type
   =post&category_name=Neuigkeiten&post_date=’2012-08-30′”
 * With and without quotes on the date
    it follows with: $query = new WP_Query; 
   $posts = $query->query($q);
 * The query result works with all conditions except the date.
 * When I try something like date >=, then I get back the name with >
    Looks like
   there is being done a split on = or something like that.
 * What? I am doing wrong, or where can I found the right information?
    I found 
   on Internet a lot information, but the solution are not very useful. It should
   be something simple. Al solutions don’t cover the whole thing, while it is so
   simple.
 * I hope someone can help me out.
 * Best solution is of course that WordPress self is able to batch delete posts 
   categories and not just put a new category to a post.
 * With regards,
 * Cees Stoltenkamp

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [cstoltenkamp](https://wordpress.org/support/users/cstoltenkamp/)
 * (@cstoltenkamp)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/query-posts-on-date/#post-3023940)
 * Found a solutions
 *  $fdate = $_GET[‘iDate’];
    $dt = split(‘-‘, $fdate); $q .= ‘&year=’ . $dt[0];
   $q .= ‘&monthnum=’ . $dt[1]; $q .= ‘&day=’ . $dt[2]; $query = new WP_Query; $
   posts = $query->query($q);
 * Still I cant only use is equal, is there a way to do different?
    Like $q .= ‘&
   day>=’ . $dt[2]; and Like $q .= ‘&day<=’ . $dt[2];
 * Thanks
 *  Thread Starter [cstoltenkamp](https://wordpress.org/support/users/cstoltenkamp/)
 * (@cstoltenkamp)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/query-posts-on-date/#post-3024016)
 * Found! I can make what I want, in short time I will release a New Batch Category
   with a lot of additional possibilities.
 * // Create a new filtering function that will add our where clause to the query
   
   function filter_where( $where = ” ) { // posts for March 1 to March 15, 2010 
   $where .= ” AND post_date >= ‘2010-03-01’ AND post_date < ‘2010-03-16′”; return
   $where; }
 * add_filter( ‘posts_where’, ‘filter_where’ );
    $query = new WP_Query( $query_string);
   remove_filter( ‘posts_where’, ‘filter_where’ );

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘[plugin Batch Categories] Query posts on Date’ is closed to new replies.

## Tags

 * [date](https://wordpress.org/support/topic-tag/date/)
 * [dateformat](https://wordpress.org/support/topic-tag/dateformat/)
 * [query](https://wordpress.org/support/topic-tag/query/)

 * 2 replies
 * 1 participant
 * Last reply from: [cstoltenkamp](https://wordpress.org/support/users/cstoltenkamp/)
 * Last activity: [13 years, 9 months ago](https://wordpress.org/support/topic/query-posts-on-date/#post-3024016)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
