SQL for listing all WordPress tags

Published:

When writing a post I sometimes find it difficult to choose what I should tag it with. I try reuse tags I already have to prevent a total mess, and sometimes I just don't really remember what tags I have used so far. When writing a post in WordPress you can get a list of the most used ones, but once in a while I write a post on subject I haven't written a lot about. So, instead of going to the Post Tags page and look through all the pages of tags, I decided to just connect to my blog database and run a query.

SELECT
  name, slug, description, COUNT
FROM wp_terms
  NATURAL JOIN wp_term_taxonomy
WHERE
  taxonomy="post_tag"
ORDER BY
  name

Lists all your tags, sorted by name 🙂