I'm adding voting features to a theme. Visitors can vote posts Up or Down. I created a table for storing number of votes for each post and that works fine. Now I'm trying to sort posts by their votes.
I have "voted up" and "voted down" links. For instance, when you click on "voted up" a new parameter sort=up
is passed in the URL.
In the loop if the parameter exists and is = "up" I want to loop posts with votes up.
wpdb->get_results("SELECT post_id, FROM $wpdb->votes WHERE up > 5");
This is where I want to use something like query_posts('sort=up')
before the loop. My question is, how to I create the custom "sort" parameter?