This answer was a joint effort with tnorthcutt so I haven't tested this, butmade it feels about rightcommunity wiki.
There are several interesting functions available: the_categorythe_taxonomies()
gives you all of the cats for the current post, which calls get_the_taxonomies()
, which in turn calls get_object_taxonomies()
and wp_get_object_terms()
loops through all of the supplied categories.
$terms = wp_get_object_terms($id, the_category())
the_taxonomies()
is a documented template tag and is a light wrapper around a call toget_the_taxonomies()
, which is undocumented.get_object_taxonomies()
returns a list of associated taxonomies (as simple names or as objects), which could be quite useful in certain situations. It's documented, but it's easy to miss this function because nothing links to it in the Codex. I only found it by perusingwp-includes/taxonomy.php
. There is an undocumented wrapper function around this,get_post_taxonomies()
, which defaults to the current post.wp_get_object_terms()
does most of the heavy lifting. It has two very interesting parameters: an array(!) of object ids and an array(!) of taxonomy names. It ends up generating a moderately evil-looking SELECT and returns an array of terms (as names, objects, or ... read the docs) for the given object(s) within the given taxonomy(ies).
Should you need more complex formatting than is available via the_taxonomies()
, knowing about these "inner" functions should prove useful.