I have a table that saves the ratings for each post, the table 开发者_如何学编程looks like this http://d.pr/YIxL it saves the ID of the post and the rating, I need to query the posts based on that table ASC or DSC.
I hope that the answer is clear.
This was the query that did the trick
$wp_query->request = "
SELECT $wpdb->posts.* FROM $wpdb->posts
Left join $ratings_table
ON $wpdb->posts.ID = $ratings_table.ID
Where
$wpdb->posts.post_type = 'games' AND $wpdb->posts.post_status = 'publish'
ORDER BY $ratings_table.points DESC
LIMIT $ppp OFFSET $offset";
$pageposts = $wpdb->get_results($wp_query->request, OBJECT);
精彩评论