title: Making custom column sortable in WooCommerce admin order list
body: <p>I have my custom column showing data, but I just can't seem to get it to sort. At the moment, if I press the column title for sorting, it only sorts by the date of the orders, rather than the data from this new column. I am especially stuck on what the &quot;value&quot; should be in the array for &quot;meta_query&quot; – everything I have tried hasn't worked. Any help would be much appreciated!</p>
  <pre><code>// ----- add column to orders that shows the booking date -----
  function ec_order_items_column2($columns) {
      $new_columns = array();
      foreach($columns as $key=&gt;$column){
          $new_columns[$key] = $columns[$key];
          if($key === 'ordered_products') {
              $new_columns['start_date'] = __('Booking Time','woo-custom-ec2');
          }
      }
      return $new_columns;
  
  }
  add_filter('manage_edit-shop_order_columns', 'ec_order_items_column2', 99 );
  
  
  
  
  function ec_order_items_column_cnt2($column) {
      global $post, $the_order;
      
      $order_id = $the_order-&gt;get_id();
      
      // Replace 'my_custom_column_key' with your desired column key
      if ( 'start_date' === $column ) {
          $display = array();
          
          // Loop through order items
          foreach ( $the_order-&gt;get_items() as $item_id =&gt; $item ) {
              // $item_id is the current Item ID
  
              // Get the WC_Product Object
              $product = $item-&gt;get_product();
              
              // Get custom order item meta data 
              $meta_value = $item-&gt;get_meta('phive_display_time_from');
              
              $display[$item_id] = $meta_value;
              
          }
          // Testing output
          echo implode(' | ', $meta_value);
      }
  }
  
  add_action('manage_shop_order_posts_custom_column', 'ec_order_items_column_cnt2', 99);
  
  
  
  // ---- make sortable column ----
  
  add_filter( 'manage_edit-shop_order_sortable_columns', 'custom_woo_admin_sort' );
  function custom_woo_admin_sort( $columns )
  {
      $custom = array(
          'start_date'    =&gt; '_phive_display_time_from',
      );
      return wp_parse_args( $custom, $columns );
  }
  
  
  
  add_action('pre_get_posts', 'custom_booking_orderby');
  function custom_booking_orderby( $query ) {
      if ( !is_admin() ){ return; }
  
      $orderby = $query-&gt;get( 'orderby');
      if ('phive_display_time_from' == $orderby){
        $query-&gt;set('meta_key','phive_display_time_from');
        $query-&gt;set( 'orderby', 'meta_value' );
        $query-&gt;set( 'meta_query', array(
          array(
                'key' =&gt; 'phive_display_time_from',
                'value' =&gt; 'meta_value',
          )
    ));
      }
  }
  </code></pre>