Query number posts contributor has made
-
Hi
I’m trying to make a query to find out how many posts each “Contributor” has made within a category (ID=5). just to be clear, “Contributor” has a “wp_user_level” of “1”
I have something like this so far
SELECT DISTINCT COUNT(wp_posts.post_author) as thecount
FROM wp_users INNER JOIN wp_usermeta ON (wp_users.ID = wp_usermeta.user_id), wp_posts LEFT JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) LEFT JOIN wp_term_taxonomy ON (wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id)
WHERE wp_term_relationships.term_taxonomy_id IN (5)
AND wp_usermeta.meta_key = ‘wp_user_level’
AND wp_usermeta.meta_value = ‘1’
AND wp_posts.post_status = ‘publish’
AND wp_posts.post_type = ‘post’
GROUP BY wp_posts.post_author
ORDER BY thecount DESCThen after this I have a foreach thing going, but when I output the $variable->thecount, it outputs the total number of posts that exist in category(5) rather than the number that specific Contributor has posted
Any help is greatly appreciated!
- The topic ‘Query number posts contributor has made’ is closed to new replies.