[wp-hackers] popular posts plugin - exclude a category.

Paul Anthony paul at webdistortion.com
Thu Feb 18 15:58:12 UTC 2010


Hi guys, this is my first post in the list. I'm using a modified popular
posts plugin and need to exclude all posts within a certain category. The
below statement doesn't seem to be working, and I'm wondering if someone
more familiar with the schema can shed any light? The parent category ID is
20 - I'd also like to exclude any sub categories of that category, but that
isn't as big a priority.





SELECT wp_posts.ID, wp_posts.post_title ,
(SUM(wp_popularpostsdatacache.pageviews)) AS 'pageviews' ,
wp_posts.comment_count AS 'comment_count' FROM wp_posts RIGHT JOIN
wp_popularpostsdatacache ON wp_posts.ID = wp_popularpostsdatacache.id WHERE
wp_posts.post_status = 'publish' AND wp_posts.post_password = '' AND
wp_popularpostsdatacache.day >= '2010-02-18' - INTERVAL 7 DAY

/*thinkthe problem is here..*/

AND wp_posts.ID NOT IN (SELECT term_taxonomy_id FROM wp_term_relationships
WHERE term_taxonomy_id IN (20))

/*.*/


GROUP BY wp_posts.ID ORDER BY pageviews DESC LIMIT 5


More information about the wp-hackers mailing list