有点复杂,但:
<?php
function get_single_term($post_id, $taxonomy)
{
$terms = wp_get_object_terms($post_id, $taxonomy);
if(!is_wp_error($terms))
{
return \'<a href="\'.get_term_link($terms[0]->slug, $taxonomy).\'">\'.$terms[0]->name.\'</a>\';
}
}
//example
echo get_single_term(5, \'category\');