diff --git a/woocommerce-ajax.php b/woocommerce-ajax.php index 43e70364621..f7d91df245c 100644 --- a/woocommerce-ajax.php +++ b/woocommerce-ajax.php @@ -1819,13 +1819,13 @@ function woocommerce_product_ordering() { $nextid = isset( $_POST['nextid'] ) ? $_POST['nextid'] : false; $new_pos = array(); // store new positions for ajax - $siblings = $wpdb->get_results( $wpdb->prepare(" - SELECT ID, menu_order FROM %s AS posts - WHERE posts.post_type = 'product' - AND posts.post_status IN ( 'publish', 'pending', 'draft', 'future', 'private' ) - AND posts.ID NOT IN (%s) + $siblings = $wpdb->get_results( $wpdb->prepare(' + SELECT ID, menu_order FROM %1$s AS posts + WHERE posts.post_type = \'product\' + AND posts.post_status IN ( \'publish\', \'pending\', \'draft\', \'future\', \'private\' ) + AND posts.ID NOT IN (%2$d) ORDER BY posts.menu_order ASC, posts.ID DESC - "), $wpdb->posts, $post->ID ); + ', $wpdb->posts, $post->ID) ); $menu_order = 0;