WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have some categories which are not correctly defined. I.e. their parents are messed up. How can I select with SQL all categories and their parents?

share|improve this question

Something like this should work:

select t.name cat, p.name parent 
from wp_terms t, wp_term_taxonomy tt, wp_terms p
where tt.term_id=t.term_id and tt.parent=p.term_id

(this only returns categories with a parent)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.