1

I get terms from all my posts with get_terms,

$tags = get_terms( 'mytags', '&number=5&orderby=date&order=desc&hide_empty=1' );
foreach ( $tags as $tag ) {
    echo '<a href="'.get_bloginfo('url').'/tags/'.$tag->slug.'">'.$tag->name.'</a>';
}

Is it possible to get_terms included to the posts made by author? I try to add a list with all the terms (tags) in author.php template,

thanks a lot!

1
  • Terms aren't specific to author, they're specific to post types or posts, please clarify your question.
    – t31os
    Commented Dec 10, 2011 at 18:38

1 Answer 1

5

Not directly, because terms are assigned to posts, not authors.

You will need to query all posts, get their terms and authors, and then filter out terms which came with posts that have other authors than get_query_var('author').

Note that depending on the number of posts your site has, this kind of query could be very expensive. A better way would be to either record term IDs inside an user meta key during save_post (still kind of slow), or create your own table with the data you need (fast).

1
  • Possibly I think it's better to query posts under the author - instead of ALL posts. That's probably going to cause some performance issues there. When you have posts from the other, you can then continue the same process. Commented Feb 1, 2021 at 20:37

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.