I am using a custom post type in my website and a custom taxonomy for it.

An author selects one or many terms before publishsing its post.

My goal is to display authors pages in front end, so I am using author.php template file. This file is by default displaying the archive of posts written by the specific author. How can I add to this file the list of the custom taxonomy terms for the author published posts?

I give the following example if I wasn't clear in my explanation:

if Author-x has published:

**post1** with term1 , term2, term3
**post2** with term2, term5
**post3** with term1

then, in Author-x page I will have : term1, term2, term3, term5.

It is exactly the same principle as in user page in stack exchange. As you can see, there is a list of tags for each user which are tags of posts the user contributed in.

Thank you for your usual help.

1 Answer 1


First get a list of the author posts then loop over the each post and get the terms used ex:

function list_author_used_terms($author_id){

    // get the author's posts
    $posts = get_posts( array('post_type' => 'custom_post_type_name', 'posts_per_page' => -1, 'author' => $author_id) );
    $author_terms = array();
    //loop over the posts and collect the terms
    foreach ($posts as $p) {
        $terms = wp_get_object_terms( $p->ID, 'taxonomy_name');
        foreach ($terms as $t) {
            $author_terms[] = $t->name;
    return array_unique($author_terms);

echo implode(", ",list_author_used_terms(1));
  • Thank you @bainternet for your help. i will test and come back give feedback Commented Jun 10, 2013 at 11:25
  • test away , but remember its an example :)
    – Bainternet
    Commented Jun 10, 2013 at 11:26
  • I did all the necessary changes (changed post to custom post type name, and changed post_tag to my taxonomy name) but it is still giving me an empty array for author with id=1 even this author has posts with terms. also I print_r the $posts variable after get_posts and it is ok.!!!! Commented Jun 10, 2013 at 12:00
  • It is okey and thank you very much, I understand now that you gave me just the algorithm not the code. but you should know that the only mistake you did is : name instead of term_name. Perfect Bainternet. Commented Jun 10, 2013 at 12:08
  • 1
    Glad you figured it out
    – Bainternet
    Commented Jun 10, 2013 at 13:04

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.