我接受了小马的回答,因为它让我走上了正确的道路,并且回答了我的问题。然而,在最后我使用它时,它会返回带有其分类字段的完整术语对象。虽然有点黑。。。
/**
* Get ther without khowing it\'s taxonomy. Not very nice, though.
*
* @uses type $wpdb
* @uses get_term()
* @param int|object $term
* @param string $output
* @param string $filter
*/
function &get_term_by_id($term, $output = OBJECT, $filter = \'raw\') {
global $wpdb;
$null = null;
if ( empty($term) ) {
$error = new WP_Error(\'invalid_term\', __(\'Empty Term\'));
return $error;
}
$_tax = $wpdb->get_row( $wpdb->prepare( "SELECT t.* FROM $wpdb->term_taxonomy AS t WHERE t.term_id = %s LIMIT 1", $term) );
$taxonomy = $_tax->taxonomy;
return get_term($term, $taxonomy, $output, $filter);
}