Title: WP_Query ONLY Future Posts
Last modified: November 9, 2022

---

# WP_Query ONLY Future Posts

 *  Resolved [rftbdev](https://wordpress.org/support/users/rftbdev/)
 * (@rftbdev)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/wp_query-only-future-posts/)
 * The following code will output events in an ascending manner, but it will also
   retrieve past events.
 *     ```
       <?php
   
         $args = array(
         'post_type' => 'event',
         'posts_per_page' => -1,
         'meta_key' => '_event_start_date',
         'orderby' => '_event_start_date',
         'order' => 'ASC',
         );
   
         $posts = get_posts($args);
         $chunked = array_chunk($posts, 6, false);
   
         foreach ($chunked as $chunk) :
           get_template_part('template-parts/grids/events-grid', null, [
           'posts' => $chunk,]);
         endforeach;
   
         wp_reset_postdata();
       ?>
       ```
   
 * I only want to show events that are in the scope ‘future.’ Unfortunately, it 
   appears that you cannot pass the ‘scope’ in the $args array to the WP_Query (
   in my case get_posts())
 * With that being said, I tried to use ‘compare’ => ‘>=’ against a ‘value’ => $
   today
 *     ```
       $today = date('Y-m-d'); (this is the format of the date in the database)
       ```
   
 *     ```
       $args = array(
         'post_type' => 'event',
         'posts_per_page' => -1,
         'meta_key' => '_event_start_date',
         'orderby' => '_event_start_date',
         'order' => 'ASC',
         // 'meta_value' => $today, (this format will not retrieve any posts)
         'value' => $today, (this format will not filter events greater than or equal to 
          today)
         'compare' => '>=',
       );
       ```
   
 * Any help is much appreciated.
 * The goal is to query all future/upcoming events, to exclude past events.
    -  This topic was modified 3 years, 6 months ago by [rftbdev](https://wordpress.org/support/users/rftbdev/).

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

 *  [bojates](https://wordpress.org/support/users/bojates/)
 * (@bojates)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/wp_query-only-future-posts/#post-16182122)
 * This isn’t a direct answer to your question, but might help. I guess there’s 
   a reason you’re not using this, but just in case you missed it, you can do this:
 * `echo EM_Events::output(array('scope'=>'tomorrow', 'limit'=>10, 'pagination'=
   >1));`
 * And obviously don’t need to echo that, but can manipulate as necessary.
 * [https://wp-events-plugin.com/documentation/event-search-attributes/](https://wp-events-plugin.com/documentation/event-search-attributes/)
    -  This reply was modified 3 years, 6 months ago by [bojates](https://wordpress.org/support/users/bojates/).
 *  Thread Starter [rftbdev](https://wordpress.org/support/users/rftbdev/)
 * (@rftbdev)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/wp_query-only-future-posts/#post-16182228)
 * Thank you bojates. This definitely gets me somewhere. I appreciate your feedback!!
 *  Thread Starter [rftbdev](https://wordpress.org/support/users/rftbdev/)
 * (@rftbdev)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/wp_query-only-future-posts/#post-16182248)
 * I need to return an array not a string. I am trying to print the returned value
   to discern what will be used as the separator for the explode() function
 * $posts = EM_Events::get(array(‘scope’=>’future’), false); ?
    -  This reply was modified 3 years, 6 months ago by [rftbdev](https://wordpress.org/support/users/rftbdev/).
 *  Thread Starter [rftbdev](https://wordpress.org/support/users/rftbdev/)
 * (@rftbdev)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/wp_query-only-future-posts/#post-16182281)
 * THANK YOU bojates! 🙂 HAPPY CODING!
 *  Thread Starter [rftbdev](https://wordpress.org/support/users/rftbdev/)
 * (@rftbdev)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/wp_query-only-future-posts/#post-16182286)
 * SOLVED [@bojates](https://wordpress.org/support/users/bojates/)
 *  [bojates](https://wordpress.org/support/users/bojates/)
 * (@bojates)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/wp_query-only-future-posts/#post-16182293)
 * Ace 😀

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

The topic ‘WP_Query ONLY Future Posts’ is closed to new replies.

 * ![](https://ps.w.org/events-manager/assets/icon-256x256.png?rev=3550347)
 * [Events Manager - Calendar, Bookings, Tickets, and more!](https://wordpress.org/plugins/events-manager/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/events-manager/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/events-manager/)
 * [Active Topics](https://wordpress.org/support/plugin/events-manager/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/events-manager/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/events-manager/reviews/)

## Tags

 * [Future Events](https://wordpress.org/support/topic-tag/future-events/)
 * [wp_query](https://wordpress.org/support/topic-tag/wp_query/)

 * 6 replies
 * 2 participants
 * Last reply from: [bojates](https://wordpress.org/support/users/bojates/)
 * Last activity: [3 years, 6 months ago](https://wordpress.org/support/topic/wp_query-only-future-posts/#post-16182293)
 * Status: resolved