Skip to content

Instantly share code, notes, and snippets.

@rdlmda
Last active March 18, 2021 13:46
Show Gist options
  • Save rdlmda/e6363f78893d438917c1bba87326cd4d to your computer and use it in GitHub Desktop.
Save rdlmda/e6363f78893d438917c1bba87326cd4d to your computer and use it in GitHub Desktop.
WordPress: count posts by year and month
SELECT YEAR(post_date) YEAR, MONTH(post_date) MONTH, COUNT(*) COUNT
FROM wp_posts
WHERE post_type = 'post' AND post_status = 'publish'
GROUP BY YEAR(post_date), MONTH(post_date);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment