Title: Query posts made AFTER given date?
Last modified: August 19, 2016

---

# Query posts made AFTER given date?

 *  [Janko](https://wordpress.org/support/users/janko/)
 * (@janko)
 * [18 years, 3 months ago](https://wordpress.org/support/topic/query-posts-made-after-given-date/)
 * Hi,
    I would like to list posts filtering these, which has been **written after
   particular date**, in example only posts after 28 February.
 * I suppose it should be done by _query\_posts_ tag but I have no idea how to use
   it with variable date 🙁 .
    Please help me to find a solution…
 * Best Regards,
    Janko

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

 *  [Jeremy Clark](https://wordpress.org/support/users/jeremyclark13/)
 * (@jeremyclark13)
 * [18 years, 3 months ago](https://wordpress.org/support/topic/query-posts-made-after-given-date/#post-703840)
 * Here is the doc on the query_posts tag with how to pass variables to it.
    [http://codex.wordpress.org/Template_Tags/query_posts#Passing_variables_to_query_posts](http://codex.wordpress.org/Template_Tags/query_posts#Passing_variables_to_query_posts)
 *  Thread Starter [Janko](https://wordpress.org/support/users/janko/)
 * (@janko)
 * [18 years, 3 months ago](https://wordpress.org/support/topic/query-posts-made-after-given-date/#post-703843)
 * Hi, thanks for quick reply.
    Ok, I can use it, setting current date as a variable,
   but I have no idea how to tell WordPress, that it should show posts after this
   date..
 *  [Jeremy Clark](https://wordpress.org/support/users/jeremyclark13/)
 * (@jeremyclark13)
 * [18 years, 3 months ago](https://wordpress.org/support/topic/query-posts-made-after-given-date/#post-703844)
 * What exactly are you wanting to accomplish? Just explain what you want then we
   can go about getting the right solution to the problem.
 *  Thread Starter [Janko](https://wordpress.org/support/users/janko/)
 * (@janko)
 * [18 years, 3 months ago](https://wordpress.org/support/topic/query-posts-made-after-given-date/#post-703846)
 * I’m creating posts with a timestamp in the future (and plugn that enables WP 
   to show them) and I want to reject from showing posts that are “older” than today.
 *  [Jeremy Clark](https://wordpress.org/support/users/jeremyclark13/)
 * (@jeremyclark13)
 * [18 years, 3 months ago](https://wordpress.org/support/topic/query-posts-made-after-given-date/#post-703857)
 * Is this for a band website? If so there is already a plugin that will do that
   for you.
    [http://wordpress.org/extend/plugins/gigpress/](http://wordpress.org/extend/plugins/gigpress/)
 *  Thread Starter [Janko](https://wordpress.org/support/users/janko/)
 * (@janko)
 * [18 years, 3 months ago](https://wordpress.org/support/topic/query-posts-made-after-given-date/#post-703858)
 * Yeah, using it on another site 😉 .
    Well, that’s not a bad idea, I’ll try to
   find what I need inside plugin. I’ll write about results.
 *  Thread Starter [Janko](https://wordpress.org/support/users/janko/)
 * (@janko)
 * [18 years, 3 months ago](https://wordpress.org/support/topic/query-posts-made-after-given-date/#post-703874)
 * I struggled through the plugin and I think there are no useful things for this
   case.
    It is possible to show only future posts – one have to not use future-
   post-showing plugins and create new post with future timestamp. Then it can be
   done with this code:
 *     ```
       <?php
       query_posts('post_status=future');
       ?>
       ```
   
 * Ok, It works. Next step is to do something similiar with main WP loop.
 * The problem with plugins that enables showing future posts is that they are messing
   with “future” post status (usually just avoiding WP to set it when saving post)
   and then this code can’t be used. Well, maybe there is another method to show
   such posts…
 * Anyway, maybe easier would be to modify the loop itself and I can’t do that again:/…
   
   If I understand it right then it would be good idea to do something like post_status
   =publish+future – obviously not with this syntax. How to do that?
 *  Thread Starter [Janko](https://wordpress.org/support/users/janko/)
 * (@janko)
 * [18 years, 3 months ago](https://wordpress.org/support/topic/query-posts-made-after-given-date/#post-703882)
 * Well, it seems I have solution!
    I found older version of _The Future Is Now_
   plugin, here we go:
 *     ```
       <?php
       /*
       Plugin Name: The Future is Now!
       Description: Display posts with a timestamp in the future.
       Version: R1.0.1
       */
   
       function show_future_where($where) {
       	global $wpdb;
   
       	if( !is_single() && !is_page() )
       		$where .= " OR $wpdb->posts.post_status = 'future' ";
   
       	return $where;
       }
   
       add_filter('posts_where', 'show_future_where');
       ?>
       ```
   
 * **Why I think it is better?**
    It makes future posts being displayed in the loop
   but it doesn’t change post_status, so I can easlily display only the future posts
   with _query\_posts_ and _post\_status=future_. Am I right or there is something
   wrong about it?
 * (got it from here [http://comox.textdrive.com/pipermail/wp-hackers/2007-November/016104.html](http://comox.textdrive.com/pipermail/wp-hackers/2007-November/016104.html))
 *  Thread Starter [Janko](https://wordpress.org/support/users/janko/)
 * (@janko)
 * [18 years, 3 months ago](https://wordpress.org/support/topic/query-posts-made-after-given-date/#post-704209)
 * Oh danm, I was sure it works, but there is still a problem with it.
 * **When user is not admin the mentioned plugin doesn’t allow to view him a page
   of post in the future** – and in this case anyone should be able to view it.
 * Please, who knows how to fix it? So how to let anyone read (full) future posts?
   
   Regards, Janko
 *  Thread Starter [Janko](https://wordpress.org/support/users/janko/)
 * (@janko)
 * [18 years, 2 months ago](https://wordpress.org/support/topic/query-posts-made-after-given-date/#post-704226)
 * Eh, bump 🙁 …
 * What to add or change in this plugin to let everyone, not only admin, read future
   posts?
 *     ```
       <?php
   
       function show_future_where($where) {
       	global $wpdb;
   
       	if( !is_single() && !is_page() )
       		$where .= " OR $wpdb->posts.post_status = 'future' ";
   
       	return $where;
       }
   
       add_filter('posts_where', 'show_future_where');
       ?>
       ```
   
 * I was looking for some clues here [http://codex.wordpress.org/Option_Reference](http://codex.wordpress.org/Option_Reference)
   
   and here [http://codex.wordpress.org/Roles_and_Capabilities](http://codex.wordpress.org/Roles_and_Capabilities)
   and even here [http://codex.wordpress.org/Plugin_API](http://codex.wordpress.org/Plugin_API)…
   and didn’t found anything… 🙁
 *  [twopeak](https://wordpress.org/support/users/twopeak/)
 * (@twopeak)
 * [17 years, 8 months ago](https://wordpress.org/support/topic/query-posts-made-after-given-date/#post-704291)
 * I was trying to reach the same: the front page should show a small calendar with
   the 5 **next **gigs; and a full calendar shows all previous and future gigs.
 * I was trying to use this:
 *     ```
       $string='monthnum>'.date('m').'&order=ASC&showposts=6';
       query_posts($string);
       ```
   
 * This works if I choose a specific year; it doesn’t work for monthnum.
    Further
   this is not a solution because it will only ‘refresh’ itself once a month, not
   every day.
 * In the database there’s a field called post_date
    it must somehow be possible
   to alter the query somewhere; I’ll be searching into this.
 *  [twopeak](https://wordpress.org/support/users/twopeak/)
 * (@twopeak)
 * [17 years, 8 months ago](https://wordpress.org/support/topic/query-posts-made-after-given-date/#post-704292)
 * [http://codex.wordpress.org/Displaying_Posts_Using_a_Custom_Select_Query](http://codex.wordpress.org/Displaying_Posts_Using_a_Custom_Select_Query)
   
   this should do it; however I didn’t have any luck yet at creating my sql; I’m
   terrible with joins and seemingly this is a must since version 2.3… 🙁
 *  [twopeak](https://wordpress.org/support/users/twopeak/)
 * (@twopeak)
 * [17 years, 7 months ago](https://wordpress.org/support/topic/query-posts-made-after-given-date/#post-704296)
 * For those interested:
    I had a plugin that printed the sql that wordpress uses
   standard: [http://wordpress.org/support/topic/159930?replies=1](http://wordpress.org/support/topic/159930?replies=1)
 * From this I built this query:
 *     ```
       SELECT SQL_CALC_FOUND_ROWS wp_posts. *
       FROM wp_posts
       WHERE 1 =1
       AND wp_posts.post_type = 'post'
       AND (
       wp_posts.post_status = 'publish'
       OR wp_posts.post_status = 'private'
       )
       AND wp_posts.post_date >= CURDATE( )
       ORDER BY wp_posts.post_date ASC
       LIMIT 0 , 10
       ```
   
 * it seems to work at first sight!

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

The topic ‘Query posts made AFTER given date?’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 13 replies
 * 3 participants
 * Last reply from: [twopeak](https://wordpress.org/support/users/twopeak/)
 * Last activity: [17 years, 7 months ago](https://wordpress.org/support/topic/query-posts-made-after-given-date/#post-704296)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
