Echo taxonomy term meta on author.php

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.

Leave a Comment