Basically I have a post type called photograph, I then have a Taxonomy group called "Subject" and several tax terms i.e. Abstract, freeze frame etc (Approx 18 in total) under that Taxonomy group.

I then have a custom author template, where it displays the current authors posts (which are CPT's) and I am looking for a way to output the following for the current author:

<h2>Term 1</h2>
    <li>Photograph cpt, term 1, post 1</li>
    <li>Photograph cpt, term 1, post 2</li>
    <li>Photograph cpt, term 1, post 3</li>

    <h2>Term 2</h2>
    <li>Photograph cpt, term 2, post 1</li>
    <li>Photograph cpt, term 2, post 2</li>
    <li>Photograph cpt, term 2, post 3</li>


I am seriously desperate, and would very much appreciate any help or direction with this.

Thanks in advance.

  • I don't follow, sorry. Can you update the question to make it more clear what the desired result would be please. – t31os May 2 '13 at 14:05
  • Hey t31os, Sorry my lack of experience and jargon, probably makes my question read like hieroglyphics... I have updated it. – Lawless May 2 '13 at 14:53
  • And are you expecting these posts to have only a single term in this taxonomy? Else what output do you expect when there are term intersections, ie. a post has several of those terms(and not just one, per your example). – t31os May 2 '13 at 16:21
  • Oh, It would be great if that post displayed under each term. i.e. if checked for 3 terms it should display under each of those 3 terms... Hope that answers your question :) thanks – Lawless May 3 '13 at 7:05
  • as they will be display using jQuery in a gallery type manner. each term will be a button, that when clicked will display the relevant posts for that term. – Lawless May 3 '13 at 8:13

Got the answer, encase anyone else needs it, here it is.


$currauthor_id = get_the_author_meta('ID');

$terms = get_terms('your_taxonomy', array(

     'orderby'    => 'name',         

         'order'    => 'ASC',

     'hide_empty' => 1,

    ) );

foreach ( $terms as $term ) {       

    $myquery = new WP_Query( array(

        'author' => $currauthor_id,

        'post_type' => 'post_type_name',

        'your_taxonomy' => $term->slug,

        'posts_per_page' = > -1,



    <h2>Term: <?php echo $term->name; ?></h2>


    <?php if ( $myquery->have_posts() ){ 

        while ( $myquery->have_posts() ) : $myquery->the_post(); ?>

            <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>

    <?php endwhile; } ?>


    <?php wp_reset_postdata();?>        

<?php } ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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