[wp-hackers] categories with no childs
Dion Hulse (dd32)
wordpress at dd32.id.au
Sun May 30 01:19:04 UTC 2010
On Sun, 30 May 2010 09:17:43 +1000, Charles K. Clarkson
<cclarkson at htcomp.net> wrote:
> Dion Hulse (dd32) wrote:
>
> : capsx wrote:
>
> : : which is the easiest way to get wordpress categories with no child
> : : categories?
>
> : $terms_Without_children = get_terms('category', array('hide_empty' =>
> false,
> : 'parent' => '0', 'exclude' => $terms_with_children ));
> : // Fetch terms with a Parent of 0 (ie. top level), which are not in
> : the list of terms with known children
>
> That looks like a better solution, but what about child categories
> (not top level) which have no child categories? Why the top level
> category restriction?
My understanding was that the original question was for top level
categories without children.
If you remove 'parent' => 0 from the get_terms call, you'll get all
categories without children, I just thought that seemed a bit strange
myself..
But theres no technical reason why you -have- to exclude non-top-level
categories.
Cheers
Dion Hulse / dd32
Contact:
e: contact at dd32.id.au
Web: http://dd32.id.au/
More information about the wp-hackers
mailing list