0

I have used the excellent tutorial of Justin Tadlock on Custom user taxonomies in WordPress to add a Blog custom taxonomy to both my Posts post_type as well as the user object_type.

In his tutorial Justin then outputs a list of users that share the same (profession) taxonomy.

I on the other hand would like to output the specific term of my Blog taxonomy on the author.php archive, together with some other user_meta-fields I already have added to the User Profile.

How would I be able to accomplish this? Ideally it not only outputs the taxonomy term, but also a link to the term archive.

2
  • You want to output categories, for example, assigned to posts that your author has written?
    – s_ha_dum
    Commented Jul 18, 2013 at 2:43
  • @s_ha_dum I have a custom taxonomy called "Blog" which is attached to the Post post_type and the User object_type according to the tutorial linked above. When on the author.php it usually shows the profile of the author and then lists the Posts written by that author, correct? Now in that profile I want to output the associated Blog (incl. link). I hope now it's more clear.
    – user2015
    Commented Jul 18, 2013 at 3:35

1 Answer 1

1

I found my own answer in the Codex.

In my use case scenario:

$blog_terms = wp_get_object_terms( $post->ID, 'blog' );
if ( ! empty( $blog_terms ) ) {
  if ( ! is_wp_error( $blog_terms ) ) {
    foreach( $blog_terms as $term ) {
      echo '<p>' . __( 'Associated Blog: ', 'wys' ) . '<a href="' . get_term_link( $term->slug, 'blog' ) . '">' . $term->name . '</a></p>'; 
    }
  }
}

Your Answer

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