$term accounting for the possibility // that $terms is either a tid, a $term, an array of tids, or an array of $term objects if (is_array($terms) && count($array) > 0) { foreach ($terms as $term) { if (is_numeric($term)) { $term = taxonomy_get_term($term); } if (is_object($term)) { $tids[$term->tid] = $term; } } } else { if (is_numeric($terms)) { $tids[$terms] = taxonomy_get_term($terms); } elseif (is_object($terms)) { $tids[$terms->tid] = $terms; } } // build the $path $path = 'taxonomy/term'; $op = strtolower($op); switch ($op) { case 'and': $path .= '/'. implode(',', array_keys($tids)); break; case 'or': $path .= '/'. implode('+', array_keys($tids)); break; } if ($depth > 0) { $path .= "/$depth"; } if ($feed) { if ($depth > 0) { $path .= '/feed'; } else { $path .= '0/feed'; } } return $path; }