Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Vote it up plugin WordPress

  • REFUNDED

How can i use this plugin to only pull posts from one category?

This best explains: http://wordpress.org/support/topic/plugin-vote-it-up-show-top-voted-post-in-index-page?replies=5

Answers (2)

2010-08-03

Agent Wordpress answers:

Use the code given here, http://wordpress.org/support/topic/plugin-vote-it-up-show-top-voted-post-in-index-page?replies=5

but change the query to this,

$querystr = "
SELECT *
FROM $wpdb->posts
WHERE post_status = 'publish'
AND post_type = 'post'
AND $wpdb->term_taxonomy.term_id IN (22)
AND $wpdb->term_taxonomy.taxonomy = 'category'
ORDER BY post_date DESC
";


also don't forget to replace the term_id (22 in code above) with your category id.


marcus comments:

Thanks for the reply! i tried replacing the query, but now i get "sorry posts not found", im running this in wordpress 3, but i think its still written for 2.9.2. If you look on this page: http://wordpress.org/extend/plugins/vote-it-up/other_notes/ there is a function to "SortVotes():".

I have no idea how to use this function in a theme, everything i try i get errors!


Agent Wordpress comments:

Did you have voted posts in the category you need? Did you replace 22 with your own category's id?


marcus comments:

Yes i have posts in my category "top-10" ID (7)!

2010-08-06

enodekciw answers:

$querystr = "
SELECT *
FROM $wpdb->posts
LEFT JOIN $wpdb->term_relationships
ON($wpdb->posts.ID = $wpdb->term_relationships.object_id)
LEFT JOIN $wpdb->term_taxonomy
ON($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)
WHERE $wpdb->term_taxonomy.term_id = YOUR_CAT_ID
AND $wpdb->term_taxonomy.taxonomy = 'category'
AND $wpdb->posts.post_status = 'publish'
AND $wpdb->posts.post_type = 'post'
ORDER BY post_date DESC
";


Try this query, just don't forget to replace YOUR_CAT_ID with your category ID. It should work.


marcus comments:

This works but it still wont sort the posts via voting amount ie post with 5 votes should be first but is shown 7th.

You can view it here: http://www.rising-tide.co.uk/V3/lounge/top-ten-monthly-chart/