Guest User

Untitled

a guest
Oct 5th, 2022
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 1.54 KB | None | 0 0
  1. # count your posts on ClassicPress (works for WordPress, but you'll probably need to change the table names)
  2.  
  3. # select all posts in your blog that are published or private, and that are of the type 'post'
  4. SELECT YEAR(post_date) as year_val, COUNT(*) as total
  5. FROM cp_posts
  6. WHERE post_status IN("publish", "private") AND post_type = "post"
  7. GROUP BY YEAR(post_date);
  8.  
  9. # select only posts in your blog that are published, and that are of the type 'post'
  10. SELECT YEAR(post_date) as year_val, COUNT(*) as total
  11. FROM cp_posts
  12. WHERE post_status IN("publish") AND post_type = "post"
  13. GROUP BY YEAR(post_date);
  14.  
  15. # select all comments in your database (which are not pingbacks, and which are approved)
  16. SELECT YEAR(comment_date) as year_val, COUNT(*) as total
  17. FROM cp_comments
  18. WHERE comment_type = "comment" AND comment_approved = 1
  19. GROUP BY YEAR(comment_date);
  20.  
  21. #select comments only for posts that have the stats "publish"
  22. SELECT YEAR(c.comment_date) as year_val, COUNT(c.comment_date) as total
  23. FROM cp_posts p, cp_comments c
  24. WHERE p.post_status IN("publish") AND c.comment_type = "comment" AND c.comment_approved = 1
  25. AND c.comment_post_ID = p.ID
  26. GROUP BY YEAR(c.comment_date);
  27.  
  28. #count number of public posts for tags that appear more than once
  29. SELECT t.name, COUNT(*) AS num
  30. FROM cp_terms t, cp_term_taxonomy tx, cp_term_relationships rel, cp_posts p
  31. WHERE t.term_id = tx.term_id
  32. AND tx.term_taxonomy_id = rel.term_taxonomy_id
  33. AND p.ID = rel.object_id
  34. AND p.post_status = "publish"
  35. AND tx.taxonomy = "post_tag"
  36. GROUP BY t.name
  37. HAVING COUNT(*) > 1;
Advertisement
Add Comment
Please, Sign In to add comment