I'm trying to achieve this

Author.php

  • Author Loop:
    • Posts loop
    • Hobbies loop
    • Schedule loop

The author.php template file has the author loop. I need to loop through some custom post types for the author, then i'll put them into their own tabs.

However, when I put a query inside the Authors loop, it loops twice & i can't figure out why.

This is the loop(s) i'm using:

          <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>



            <div class="twelvecol first clearfix"><hr />


              <?php $looped = new WP_Query(array('post_type' => 'post', 'posts_per_page' => -1 ));
               if ( $looped->have_posts() ) { 
                   while ( $looped->have_posts() ) { 
                       $looped->the_post();
                       the_title();the_content();
                   }
               }
               wp_reset_postdata(); ?>
           </div>


    <?php endwhile; else: ?>
    <p><?php _e('No posts by this author.'); ?></p>

    <?php endif; ?>

Am I missing something that'll stop it from looping twice?


Notes:

I have to have these loops within the AUTHORS LOOP because they are specific to that author, i don't want STEVE's posts to show up on HARRY's page etc

  • There might be several authors added and removed throughout the sites life, so it has to be dynamic, i can include an author in the query