• Hi,

    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
    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 🙂

Viewing 1 replies (of 1 total)
  • Thread Starter newty

    (@newty)

    I think it’s good with :

    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 wp_posts.post_date LIKE ‘2011-06-%’

    😀

Viewing 1 replies (of 1 total)

The topic ‘Count published posts for a category and month/year’ is closed to new replies.