Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

On the author template, I would like to display a list of the custom taxonomies associated to the posts written by that author.

In details: I have a "clubs" taxonomy, which is non-hierarchical and applies to Posts.

On the author template, I need to display a list of the "clubs" used by that author's Posts, as links. In this manner, i can list the clubs to which this author participates in.

Is that possible?

share|improve this question
    
Did you tried anything ? You can try first getting all of the post ids by author and then wp_get_object_terms functions to retrieve the terms by taxonomy and object_ids –  Shazzad Feb 12 at 0:42

1 Answer 1

up vote 1 down vote accepted

First grab the post ids by the author, and then the terms.

$author_id = '1234';
$taxonomy = 'clubs';

$post_ids = get_posts('fields=ids&post_type=post&post_status=publish&showposts=-1&author='. $author_id );
$clubs = wp_get_object_terms($post_ids, array($taxonomy));

$html = '<ul>';
foreach( $clubs as $club )
{
    $html .= sprintf( 
        '<li><a href="%1$s">%2$s</a></li>',
        get_term_link($club, $taxonomy),
        $club->name
    );
}
$html .= '</ul>';

echo $html;
share|improve this answer
    
Hello Shazzad, Thank you it works quite nicely, except that if a tag has been used in 2 posts, it will appear twice. But you've sent me in the right direction, so i'll pick this up as the right answer. –  pixeline Feb 12 at 8:30

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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