Skip to content

Instantly share code, notes, and snippets.

@salase
Last active February 17, 2017 20:14
Show Gist options
  • Save salase/56cc3d65debbd25e5307a8e3db9ee334 to your computer and use it in GitHub Desktop.
Save salase/56cc3d65debbd25e5307a8e3db9ee334 to your computer and use it in GitHub Desktop.
SELECT t.term_id, t.name, count(tr.object_id), t.slug
FROM `wp_term_relationships` tr
join `wp_term_taxonomy` tt on tr.term_taxonomy_id=tt.term_taxonomy_id and tt.taxonomy='category'
join `wp_terms` t on t.term_id=tt.term_id
group by t.name
order by t.name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment