I have the following query:
SELECT p.* FROM orders_items oi INNER JOIN products pr ON pr.`post_id` = oi.`product_id` INNER JOIN posts p ON p.`ID` = pr.`post_id` AND p.`post_type` = 'product' GROUP BY oi.`product_id` ORDER BY COUNT(oi.id) DESC;
I want to list the post based on the above query. Can anyone please tell me how can change the following code to incorporate above query?
$args = array( 'posts_per_page' => '10', 'post_type' => 'product', 'paged' => '1' ); global $query_string; query_posts($args);
Any help guys?