Support » Themes and Templates » Multiple Custom Taxonomy Loops with No Duplicates

  • Hi all,

    A client wants a theme that, in short, has three buckets at the top that each lists 4 new posts from a particular custom taxonomy term (my taxonomy is called “verticals” and the terms are “news”, “stories”, “essays”.

    This, I’ve accomplished, using this bit of code for each bucket.

         $taxonomy = 'verticals'; // this is the name of the taxonomy
         $terms = get_terms( $taxonomy, 'showposts=5' ); // for more details refer to codex please.
         $args = array(
            'post_type' => 'post',
    		'posts_per_page' => '4',
    		'category__not_in' => '78',
            'tax_query' => array(
                            'taxonomy' => 'verticals',
                            'field' => 'slug',
                            'terms' => 'news'
         $my_query = new WP_Query( $args );
         if($my_query->have_posts()) :
             while ($my_query->have_posts()) : $my_query->the_post(); $cnt =0;?> 
    		 <?php $c++;
    if( $c == 1) :?>
    The content for my first posts
     <?php else :?>
                 Some slightly different content for each subsequent post.
     <?php endif;?>
             <?php endwhile;?>
         <?php endif;

    Now the problem is that the client then wants another section that pulls the 10 latest posts from all terms, but doesn’t want this latter stream to duplicate any posts from any of the three buckets. Ideas?

  • The topic ‘Multiple Custom Taxonomy Loops with No Duplicates’ is closed to new replies.