Sorting Posts by Vote Count
-
I am using the following code, to show the posts in vote count order.
<?php /** * SORTS THE POSTS BY VOTE COUNT */ add_filter('posts_orderby', 'edit_posts_orderby'); add_filter('posts_join_paged','edit_posts_join_paged'); function edit_posts_join_paged($join_paged_statement) { global $wpdb; $join_paged_statement = "LEFT JOIN ".$wpdb->prefix."wpv_voting ON ".$wpdb- >prefix."wpv_voting.post_id = $wpdb->posts.ID"; return $join_paged_statement; } function edit_posts_orderby($orderby_statement) { global $wpdb; $orderby_statement = "(".$wpdb->prefix."wpv_voting.vote_count) DESC"; return $orderby_statement; } ?>
It works fine for the listing page. But when I go to a category, it doesn’t show any result.
Please help.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Sorting Posts by Vote Count’ is closed to new replies.