Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.
$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

1 Answer 1

up vote 3 down vote accepted

Any reason why you can't use WordPress API?

 $cats = get_categories(array(
          'child_of'=>1
       )); 

See Codex here.

share|improve this answer

Your Answer

 
discard

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.