What is the correct way to output taxonomy term meta associated with an object?


I have registered a custom taxonomy, "firms". This is attached only to "Users" (not something WordPress natively supports, but accomplished thanks to the LH User Taxonomies plugin).

Term meta for each "firm" are company details - a few dozen fields include "firm_geo_city" and "firm_social_twitter" etc, in addition to standard name, slug and description.

Each User can only belong to one "firm", since "single_value" is set to "true" in my taxonomy registration.

My goal is, on each user's author.php profile page, to output each of the term meta details of the firm s/he belongs to.

How do I output these details? I don't understand. I have investigated get_term_meta, but have no found success.


1 Answer 1


Via a related question, I discovered wp_get_object_terms - it seems it is that which I need.

So I am now using code like...

      $firm_terms = wp_get_object_terms( $curauth->ID,  'firm' );

      if ( ! empty( $firm_terms ) ) {
        if ( ! is_wp_error( $firm_terms ) ) {
                foreach( $firm_terms as $term ) {
                    echo '<a href="' . get_term_link( $term->slug, 'firm' ) . '">' . esc_html( $term->name ) . '</a>';

... This works okay.

Although I wish I knew how and whether to take the foreach out of this. I'm not sure that I need this here. Ideas welcome.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.