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 believe I could do this with either get_categories() or wp_list_categories() and passing a 'child_of' parameter, for example, but that would return a much larger dataset than I need.

Is there a direct call that returns the child ids for any category as a simple list (1,2,3,5, etc)?

share|improve this question
up vote 3 down vote accepted

Try this:

get_terms( 'category', "child_of=$parent&fields=ids" );
// should return an array containing the ID's of children of term $parent
share|improve this answer
@goldenapples: Is this correct? var_dump(get_terms('category', "child_of=1&fields=ids" ))? (returns array(0) { }) – Scott B Jan 12 '11 at 17:58
It looks right to me, are there children to fetch? And are they non-empty? Look at the available arguments here: core.trac.wordpress.org/browser/tags/3.0.4/wp-includes/… – goldenapples Jan 12 '11 at 18:05
just add 'show_empty=true' to the second param I think. – sanchothefat Jan 12 '11 at 18:07
Actually, I think the problem is that I'm seeding $parent with the category id, not the term_id. But shouldn't they be the same? I'm trying to list all children of the uncategorized category, which is id tag_ID 1. – Scott B Jan 12 '11 at 18:07
How about get_term_children(1,'category') ? – Scott B Jan 12 '11 at 18:21

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.