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
$cats = $wpdb->get_results('SELECT term_id, term_taxonomy_id, taxonomy, parent 
FROM wp_terms, wp_term_taxonomy 
WHERE term_id = term_taxonomy_id 
AND parent = 1
AND taxonomy = "category"', ARRAY_A);

I'm trying to get all the categories in my database that are children of the category of ID 1, but it's not working. What's wrong ?

share|improve this question
up vote 3 down vote accepted

Any reason why you can't use WordPress API?

 $cats = get_categories(array(

See Codex here.

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.