[wp-hackers] get_categories() question

Michael D Adams mda at blogwaffe.com
Thu Aug 5 08:33:51 UTC 2010

On Wed, Aug 4, 2010 at 11:35 PM, Scott Bressler <sbressler at gmail.com> wrote:
> This should be really easy, but I can't figure it out. I'm trying to use
> get_categories to list all the top-level categories of a blog.
> wp_list_categories, which calls get_categories, allows for a 'depth'
> parameter, and it functions as expected. However, get_categories seemingly
> doesn't allow for this same parameter. Is there a way to use get_categories
> to only get the top-level categories? What about if I wanted to get the
> top-level terms of any taxonomy?

$root_categories = get_categories( array(
	'parent' => 0,
) );

$root_my_tax = get_terms( 'my_tax', array(
	'parent' => 0,
) );

I responded to the thread you linked:

More information about the wp-hackers mailing list