Change to filter by vocabulary instead of term .
Last modified: November 12, 2007 - 22:05
I wanted to show most recent post under all term in specified vocabulary.
<?php
$vocab_id='1';
$list_no = 5;
$query = "SELECT DISTINCT n.nid, n.title, n.created FROM {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid JOIN term_data td on tn.tid=td.tid WHERE td.vid=$vocab_id AND n.status = 1 ORDER BY n.created DESC LIMIT $list_no";
$sql = db_rewrite_sql($query);
$result = db_query($sql);
$items = array();
while ($anode = db_fetch_object($result)) {
$term_names = array();
# gather, into $term_names, all the terms because of which this node was selected:
foreach (taxonomy_node_get_terms($anode->nid) as $term) {
$term_names[] = $term->name;
}
$items[]= l($term->name, "taxonomy/term/$term->tid");
}
if(count($items)) {
print theme('item_list',$items) . '<a href=link>more</a>';
}
?>