How to print taxonomy term name with published node count and with a custom link? How can I print taxonomy name with published node count with a custom link?

eg: Taxonomy term-a (23) Taxonomy term-b (10) Taxonomy term-c (55)

I need to link each of them to a separate page.

I found this below code to print taxonomy term with count. but now how to make to print specific taxonomy term with it's node count? so that I can link it to a page later, so if I repeat the same code with different term ids to have multiple terms with its count.

    &lt;?php
$vid = 23;  // Set the vid to the vocabulary id of the vocabulary you wish to list the terms from
$parent = 130;

$terms = taxonomy_get_tree($vid, $parent, -1, 1);
foreach ( $terms as $term ) {
  $count = db_result(db_query("SELECT COUNT(n.nid) FROM {node} n INNER JOIN {term_node} t ON n.nid = t.nid WHERE t.tid = %d AND n.status = %d", $term-&gt;tid, 1));
  {
    print '&lt;div&gt;' . l($term-&gt;name, "taxonomy/term/$term-&gt;tid") . " ($count)"  . '&lt;/div&gt;';
  }
}
?&gt;


Can someone please help me?

__HAD TO ANSWER HERE AS I CAN'T AT THE BOTTOM__

This is it!!!

Took a while to write this code... :(

&lt;?php
$tid = 100;
$term = taxonomy_get_term($tid);
$name = $term-&gt;name;
$result = db_result(db_query("SELECT COUNT(n.nid) FROM {node} n INNER JOIN {term_node} t ON n.nid = t.nid WHERE t.tid = %d AND n.status = %d", $term-&gt;tid, 1));
print '&lt;div&gt;&lt;a href="http://example.com/"&gt;' . $name. " ($result)" . '&lt;/a&gt;&lt;/div&gt;';
?&gt;


Change: 100 at the second line of above code to your specific taxonomy id, that's it and repeat the same for different tid.

And make sure to change the link at the bottom from (http://example.com/) to your (custom link).

Thanks a lot to all, let me know if this code can be fine tuned further...
Although it looks like you have come up with a solution, you might want to compare against the Taxonomy List module.