[wp-testers] get_categories hierarchical not working

Austin Matzko if.website at gmail.com
Wed Jun 10 16:09:48 GMT 2009


On Wed, Jun 10, 2009 at 10:34 AM, Nathan Rice<ncrice at gmail.com> wrote:
> Then perhaps hierarchical means something different in get_categories than
> it does in get_posts. It was my understanding that the hierarchical argument
> was a sorting mechanism, returning child categories (and other descendants)
> directly after their parents.
[snip]
> That's what the argument does for get_pages at least.

I think what you're seeing with get_pages is more an accident of its
internal retrieval algorithm than anything else.  Because both
get_pages and get_categories return single-dimensional arrays, there
are a number of ways they could potentially represent the order of
hierarchical data; you mention one possibility, but I don't think that
WordPress historically has committed to any particular one, either in
documentation or common usage.

And if WordPress does end up using modified preorder tree transversal
(there's a WP Google Summer of Code project along those lines, I
believe), then you can expect the order to change again.  Perhaps we
need a parameter to specify how to order hierarchical data, or maybe
the "order" parameter can be expanded to specify such things.

 The Codex page
> indicates that as well:
> "Display sub-categories as inner list items (below the parent list item) or
> inline."

My guess is that someone has cut-and-pasted from wp_list_categories,
as get_categories doesn't return any list items.  It should be
corrected.


More information about the wp-testers mailing list