Title: Date Filter
Last modified: August 22, 2016

---

# Date Filter

 *  Resolved [rEaS](https://wordpress.org/support/users/reas/)
 * (@reas)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/date-filter/)
 * Hey, great plugin. Coming from a Drupal background, this has been a lifesaver.
   I have done everything I need with the plugin with one exception. I am trying
   to filter the view (oops, query) to just a set of specific dates. I want it to
   show posts older than 5 days ago but newer than 60 days ago. I tried playing 
   with the meta_value, but I know that date is not in fact a meta value. Can anyone
   help me with this?
 * Also not sure if the date can be restricted through the shortcode.. a.k.a. something
   like this [query slug=”homepage-most-popular” args=”start_date=5&end_date=60″],
   obviously not that but you get the idea..
 * I’d be more than happy to export the query as well if that helps in any way. 
   I’ll also be more than happy to buy someone a beer if they help me do this quickly.
   Thanks in advance!
 * [https://wordpress.org/plugins/query-wrangler/](https://wordpress.org/plugins/query-wrangler/)

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

 *  Plugin Author [Jonathan Daggerhart](https://wordpress.org/support/users/daggerhart/)
 * (@daggerhart)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/date-filter/#post-5203552)
 * Hi rEaS,
 * There isn’t a good way to do this with the args in shortcodes. What you need 
   is a date_query, and the shortcode args can’t handle array notation. [http://codex.wordpress.org/Class_Reference/WP_Query#Date_Parameters](http://codex.wordpress.org/Class_Reference/WP_Query#Date_Parameters).
 * There is a bug in the current release, or else you could handle this with a custom
   hook. I’ll try to push out a simple bug-fix-only release this evening. Then I’ll
   respond here with how to use the hook to achieve what you need.
 * Sorry for the issues, more to come this evening.
 *  Thread Starter [rEaS](https://wordpress.org/support/users/reas/)
 * (@reas)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/date-filter/#post-5203553)
 * Oh my god, thank you so much dude! I’ll be eagerly waiting for it!
 *  Plugin Author [Jonathan Daggerhart](https://wordpress.org/support/users/daggerhart/)
 * (@daggerhart)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/date-filter/#post-5203617)
 * Hi rEaS,
 * I’ve fixed the bug that was preventing the custom hooks from working correctly
   in version 1.5.25.
 * I think this code will accomplish your date_query. You’ll need to put it in your
   theme’s function.php or a custom plugin.
 *     ```
       // custom hook into query-wrangler before the query is executed
       add_filter( 'qw_pre_query', 'my_qw_pre_query_filter', 10, 2 );
   
       // my custom hook callback
       function my_qw_pre_query_filter( $args, $options ){
   
         // only alter the targeted query
         if ( 'homepage-most-popular' == $options['meta']['slug'] ){
           $args['date_query'] = array(
             'before' => '5 days ago',
             'after' => '60 days ago',
           );
         }
   
         return $args;
       }
       ```
   
 * In the future, I hope to have date_query as part of the UI. In the meantime, 
   for more options on the date query, check the codex: [http://codex.wordpress.org/Class_Reference/WP_Query#Date_Parameters](http://codex.wordpress.org/Class_Reference/WP_Query#Date_Parameters).
 * Let me know how this turns out!
 * Thanks,
    Jonathan
 *  Thread Starter [rEaS](https://wordpress.org/support/users/reas/)
 * (@reas)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/date-filter/#post-5203618)
 * ok let me try it, where do i get the latest code and whats the best way of manually
   updating a plugin in wordpress.. just copy over the files?
 *  Plugin Author [Jonathan Daggerhart](https://wordpress.org/support/users/daggerhart/)
 * (@daggerhart)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/date-filter/#post-5203619)
 * Visit your Updates page ( /wp-admin/update-core.php ). It will detect there is
   an update and let you perform the update with a click.
 * If it doesn’t list Query Wrangler there, click on “Check Again” button at the
   top. If it still doesn’t show up, give it 20 minutes and try again. Sometimes
   I have issue with very-recent updates.
 *  Thread Starter [rEaS](https://wordpress.org/support/users/reas/)
 * (@reas)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/date-filter/#post-5203620)
 * holy cow! this worked great! but great..! thank you very much, anyone needing
   to filter a query by date, just use that filter and play with the dates/days.
 * jonathan thank you so much for your help! im sending some cash your way for your
   help tomorrow when i get in the office!
 * thanks again!
 *  Plugin Author [Jonathan Daggerhart](https://wordpress.org/support/users/daggerhart/)
 * (@daggerhart)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/date-filter/#post-5203621)
 * Nice. Glad to help!

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

The topic ‘Date Filter’ is closed to new replies.

 * ![](https://ps.w.org/query-wrangler/assets/icon-256x256.jpg?rev=3279076)
 * [Query Wrangler](https://wordpress.org/plugins/query-wrangler/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/query-wrangler/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/query-wrangler/)
 * [Active Topics](https://wordpress.org/support/plugin/query-wrangler/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/query-wrangler/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/query-wrangler/reviews/)

## Tags

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

 * 7 replies
 * 2 participants
 * Last reply from: [Jonathan Daggerhart](https://wordpress.org/support/users/daggerhart/)
 * Last activity: [11 years, 9 months ago](https://wordpress.org/support/topic/date-filter/#post-5203621)
 * Status: resolved