No Result from taxonomy API function I want to output all the node IDs which belong to a taxonomy term ID. I use the following code in page--taxonomy.tpl.php.

$a = taxonomy_select_nodes(arg(2), $pager = TRUE, $limit = FALSE, $order = array('t.sticky' =&gt; 'DESC', 't.created' =&gt; 'DESC'));


When on the parent term page, print_r($a) shows an empty array. Why does this happen?

Under the parent term, there are two child terms which have some articles. How do I get the node ID?
taxonomy_select_nodes() is returning an empty array because there aren't nodes using that taxonomy term, since that function doesn't return the nodes using any children of the taxonomy term passed as argument. This is also what a taxonomy term page does.

It could be the database table used from the function doesn't contain any data, simply for the fact the taxonomy_maintain_index_table persistent variable is not set to TRUE. If that is the case, then variable_get('taxonomy_maintain_index_table') returns FALSE (or an equivalent value). A persistent variable can be overridden from the settings.php file; that is the reason I am not suggesting to check the database.

As side notes:


The page--taxonomy.tpl.php template is used not only for taxonomy/term/&lt;term id&gt;, but for any path under taxonomy, for which there isn't a taxonomy term associated. I would rather use page--taxonomy--term--%.tpl.php that is surely associated with a taxonomy term.
If you are calling a function, and want to use the default value for some of its parameters, just leave them off. Instead of calling taxonomy_select_nodes() as taxonomy_select_nodes(arg(2), $pager = TRUE, $limit = FALSE, $order = array('t.sticky' =&gt; 'DESC', 't.created' =&gt; 'DESC')), call it as taxonomy_select_nodes(arg(2)). What you are doing is assigning TRUE to the $pager local variable, FALSE to $limit (another local variable), and an array to $order; those values are also passed as arguments to the function. So you are setting local variables to pass arguments to a function, and you are passing the default values for those arguments. Keep in mind that in PHP, a function arguments are only positional, differently from Ruby, for example.