First of all, what is $post
? If you after the global $post
, then you have to declare the global in the function. So on the second line you’ll need to put global $post;
.
Secondly, $term
is an object. If you are after the term’s name, use $term->name
, for it’s slug $term->slug
.
See the Codex for some examples of how to use get_the_terms