I am looking for the query to just list the subcategories (or children) of wp_terms.term_id = 41
I need to format these is a very odd structure.
Can anyone help?
I am looking for the query to just list the subcategories (or children) of wp_terms.term_id = 41
I need to format these is a very odd structure.
Can anyone help?
Why not use the WordPress API?
$descendants = get_categories(array('child_of' => 41));
$children = get_categories(array('parent' => 41));
Note that $children will contain just the immediate child categories, but $descendants will include all descendant categories, including grand-children, great-grandchildren, etc.
That sounds great, thanks. But how do I echo that list?
$children = get_categories(array('parent' => 41));
foreach ($children as $child) {
echo $child->cat_name;
}
doesn't do anything...what am i missing?
That should work. Try var_dump($children); to see if anything's being returned.
Thanks...that did work....but not on my local box (didn't have an children there....) oops!
thanks
everything works
Thanks - this is exactly what I was looking for.
You must log in to post.