Title: Order by Start Date
Last modified: August 30, 2016

---

# Order by Start Date

 *  Resolved [jdwilliams83](https://wordpress.org/support/users/jdwilliams83/)
 * (@jdwilliams83)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/order-by-start-date/)
 * Hello,
    I am attempting to create a custom query to order the event posts by 
   event start date as compared to the current date. The goal is to to display the
   events in ascending order that are greater than are equal to the current date.
 * Do you know a way of doing this?
 * Currently my method isn’t working. Not sure this is possible with the below code
   since the date field is outputted as a string?
 * Thanks for your assistance.
 * Here’s my Code:
    `$args = array ( ‘post_type’ => ‘facebook_events’, ‘posts_per_page’
   => 6, ‘meta_query’ => array( ‘key’ => ‘event_starts’, ‘value’ => date(‘Ymd’),‘
   compare’ => ‘>=’ ), ‘orderby’ => ‘meta_value’, ‘order’ => ‘ASC’
 *  );
 * [https://wordpress.org/plugins/facebook-events-importer/](https://wordpress.org/plugins/facebook-events-importer/)

Viewing 1 replies (of 1 total)

 *  Plugin Author [WPTrashPanda](https://wordpress.org/support/users/jprescher/)
 * (@jprescher)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/order-by-start-date/#post-6192854)
 * There is a hidden sort field you could try:
 *     ```
       <?php
       event_starts_sort_field
       ?>
       ```
   
 * If you don’t want to use the current date you should be able to use it with your
   query.
 *     ```
       <?
       $currentdate = date("Y-m-d",mktime(0,0,0,date("m"),date("d")-1,date("Y")));
   
       		$args = array (
                         	'meta_query'=> array(
       	                    array(
       	                      'key' => 'event_starts_sort_field',
       	                      'compare' => '>',
       	                      'value' => $currentdate,
       	                      'type' => 'DATE',
       	                    )),
       		    'post_type' => 'facebook_events',
       			'posts_per_page' => $max,
       			'paged' => $paged,
       	        'meta_key' => 'event_starts_sort_field',
                  'orderby'=> 'modified',
                   'order' => 'DESC',
   
       		);
       ?>
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Order by Start Date’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/facebook-events-importer_212121.svg)
 * [Facebook Events Importer](https://wordpress.org/plugins/facebook-events-importer/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/facebook-events-importer/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/facebook-events-importer/)
 * [Active Topics](https://wordpress.org/support/plugin/facebook-events-importer/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/facebook-events-importer/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/facebook-events-importer/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [WPTrashPanda](https://wordpress.org/support/users/jprescher/)
 * Last activity: [10 years, 11 months ago](https://wordpress.org/support/topic/order-by-start-date/#post-6192854)
 * Status: resolved