Count published posts for a category and month/year
I would like to count published posts for a category and month/year but I can not...
I can do for a category (without set month/year) :
SELECT wp_term_taxonomy.count
FROM wp_terms, wp_term_taxonomy
WHERE wp_terms.term_id=wp_term_taxonomy.term_id
AND wp_term_taxonomy.term_id=7
but not with month/year :
SELECT count
FROM wp_term_taxonomy, wp_posts, wp_term_relationships
WHERE wp_posts.ID = wp_term_relationships.object_id开发者_JAVA技巧
AND wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id
AND wp_term_taxonomy.term_id = '7'
AND wp_posts.post_type = 'post'
AND wp_posts.post_status = 'publish'
AND wp_posts.post_date LIKE '2011-06-%'
Thanks for your help :)
SELECT COUNT(*)
FROM wp_term_taxonomy, wp_posts, wp_term_relationships
WHERE wp_posts.ID = wp_term_relationships.object_id
AND wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id
AND wp_term_taxonomy.term_id = '7'
AND wp_posts.post_type = 'post'
AND wp_posts.post_status = 'publish'
AND YEAR(wp_posts.post_date) =2011
AND MONTH(wp_posts.post_date) =6
Or replace the last two lines with between
AND wp_posts.post_date BETWEEN '2011-06-01' AND '2011-06-30'
精彩评论