Title: Query post by date
Last modified: August 21, 2016

---

# Query post by date

 *  Resolved [ecsancho](https://wordpress.org/support/users/ecsancho/)
 * (@ecsancho)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/query-post-by-date/)
 * Greetings!
 * I was wondering how I can query post by date? I need to check if there’s any 
   post made yesterday and respond accordingly. When use have_posts() and in any
   page thats not index the return results are not consistent for what I need it
   to do.
 * Much thanks!

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

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/query-post-by-date/#post-4313005)
 * [http://codex.wordpress.org/Class_Reference/WP_Query#Date_Parameters](http://codex.wordpress.org/Class_Reference/WP_Query#Date_Parameters)
 * example:
 *     ```
       $yesterday = getdate( strtotime('-1 day', strtotime("12:00:00") ) );
       $query = new WP_Query( 'year=' . $yesterday["year"] . '&monthnum=' . $yesterday["mon"] . '&day=' . $yesterday["mday"] );
       if( $query->have_posts() ) :
       //there are posts from yesterday//
       endif;
       ```
   
 *  Thread Starter [ecsancho](https://wordpress.org/support/users/ecsancho/)
 * (@ecsancho)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/query-post-by-date/#post-4313051)
 * Super helpful! Super Thanks!

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

The topic ‘Query post by date’ is closed to new replies.

## Tags

 * [have_posts()](https://wordpress.org/support/topic-tag/have_posts/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [ecsancho](https://wordpress.org/support/users/ecsancho/)
 * Last activity: [12 years, 6 months ago](https://wordpress.org/support/topic/query-post-by-date/#post-4313051)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
