[wp-hackers] categories with no childs

Dion Hulse (dd32) wordpress at dd32.id.au
Sat May 29 08:56:39 UTC 2010

I've seen a few inefficient routines suggested so far, So heres a much  
simpler one which definately works in WordPress 3.0, And i believe should  
work in 2.9 as well:

$terms_with_children = array_keys( get_option('category_children') ); //  
Use the Option cache of the hierarchy to retrieve terms which have children
$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



Dion Hulse / dd32
  e: contact at dd32.id.au
  Web: http://dd32.id.au/

On Sat, 29 May 2010 18:39:16 +1000, Charles K. Clarkson  
<cclarkson at htcomp.net> wrote:

> capsx wrote:
> : which is the easiest way to get wordpress categories with no child
> : categories?
> Please define "easiest way". :)

More information about the wp-hackers mailing list