Skip to content

Instantly share code, notes, and snippets.

@errkk
Created September 21, 2012 20:10
Show Gist options
  • Save errkk/3763626 to your computer and use it in GitHub Desktop.
Save errkk/3763626 to your computer and use it in GitHub Desktop.
Term - taxonomy relationship SQL join for WP
SELECT * FROM wp_posts p
LEFT JOIN wp_term_relationships tr ON tr.object_id = p.ID
LEFT JOIN wp_term_taxonomy tt ON tr.term_taxonomy_id = tt.term_taxonomy_id
LEFT JOIN wp_terms t ON t.term_id = tt.term_id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment