Order by meta_key in custom post type doesn’t affect the query

Please have a look in the WP_QUERY improvement and the WP_QUERY Order & Orderby Parameters.


$args = array( 
         'post_type'   => 'event',
         'post_status' => 'publish',
         'orderby' => array(
           'meta_key' => 'ASC'
          ), 
         'meta_query' => array(
           array(
             'key' => '_start_eventtimestamp',
             'value' => date('Ymd'),
             'compare' => '>='
          ),
       ),
    );

Hope it will work for you!

Leave a Comment