Last active
August 29, 2015 14:21
-
-
Save abecoffman/f29107f27e29718b6473 to your computer and use it in GitHub Desktop.
Wordpress: SQL Query Count Posts per Tag
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT count(*) AS 'TotalCount', wp_terms.name | |
FROM wp_terms | |
INNER JOIN wp_term_relationships | |
ON wp_term_relationships.term_taxonomy_id = wp_terms.term_id | |
INNER JOIN wp_term_taxonomy | |
ON wp_term_taxonomy.term_id = wp_terms.term_id AND wp_term_taxonomy.taxonomy = 'post_tag' | |
GROUP BY wp_terms.name | |
ORDER BY TotalCount DESC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment