Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Thought I would add this snippet here. Credits go to nevets from the original at http://drupal.org/node/121662#comment-250362
<?php
if ( ! function_exists('private_get_children') ) {
function private_get_children($vid, $parent = 0) {
$items = array();
$terms = taxonomy_get_tree($vid, $parent, -1, 1);
foreach ( $terms as $term ) {
$count = db_result(db_query("SELECT COUNT(nid) FROM {term_node} WHERE tid = %d", $term->tid));
$items[] = l($term->name, "taxonomy/term/$term->tid") . " ($count)" . private_get_children($vid, $term->tid);
}
if ( count($items) ) {
return theme('item_list', $items);
}
}
}
$vid = 6; // Set the vid to the vocabulary id of the vocabulary you wish to list the terms from
print private_get_children($vid);
?>