I make it progress now I have all of my shop orders but there is a new problem
it shows the shop orders that has no paid date between the other orders! they should go on the bottom of list.
function action_parse_query( $query ) {
global $pagenow;
// Initialize
$query_vars = &$query->query_vars;
// Only on WooCommerce admin order list
if ( is_admin() && $query->is_main_query() && $pagenow == 'edit.php' && $query_vars['post_type'] == 'shop_order' ) {
// Your meta key
$meta_key = '_date_paid';
// Define an additional meta query
$meta_query[] = array(
'relation' => 'OR',
array(
'key' => $meta_key,
'compare' => 'EXISTS',
),
array(
'key' => $meta_key,
'compare' => 'NOT EXISTS',
)
);
// Set
$query->set( 'orderby', 'meta_value_num' );
$query->set( 'order', 'DESC' );
$query->set( 'meta_query', $meta_query );
}
}
add_action( 'parse_query', 'action_parse_query', 10, 1 );