[wp-hackers] get_terms not working properly when using hierachical taxonomies

César Saiz emperzuco at gmail.com
Wed Feb 2 09:13:48 UTC 2011

Hey there!

I'm getting some trouble here with a plugin I'm developing which works with
a custom registered taxonomy and then generates posts listings querying more
than of those terms at once.
The taxonomy is hierarchical and I want to show on the sidebar only the
terms who was items (posts), but I don't really care if the post is in the
term itself, in a first-level child or or deep inside the navigation tree.

It should be so simple as querying get_terms() with the args hide_empty = 1
and hierarchical = 1 (default), but the mix doesn't seem to be working
properly. Instead, it returns me the terms which have posts and the terms
whose direct childrens have posts, but if the post is into a child of a
child, I got nothing.

Any idea on how to get this working properly?
This ticket seems to be about something closely related, but no specifics
are given: http://core.trac.wordpress.org/ticket/16240

I basically need to navigate the taxonomy tree all the way thorugh in order
to see if are there any posts at any level below the current term. I tried
some tricks around the get_terms filter but couldn't get it working.

Any help would be much appreciated.
Thanks in advance!!


César Saiz 'Emper'
*~ The wavelength gently grows

More information about the wp-hackers mailing list