Skip to content

Instantly share code, notes, and snippets.

@rileypaulsen
Last active December 22, 2015 11:29
Show Gist options
  • Save rileypaulsen/6465948 to your computer and use it in GitHub Desktop.
Save rileypaulsen/6465948 to your computer and use it in GitHub Desktop.
SQL select all terms from a taxonomy
SELECT a.name as term_name, wp_term_taxonomy.term_id
FROM wp_term_taxonomy
JOIN
wp_terms a
ON (wp_term_taxonomy.term_id = a.term_id)
LEFT JOIN
wp_terms b
ON (wp_term_taxonomy.parent = b.term_id)
WHERE wp_term_taxonomy.taxonomy = 'newscategory'
GROUP BY wp_term_taxonomy.term_id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment