List custom post type of several taxonomies

5

I've used this code:

<ul>
<?php
    $args = array(
        'post_type' => 'integrante',
        'orderby' => 'title',
        'order'   => 'asc',
        'lang' => 'pt',
        'tax_query' => array(
        'relation' => 'AND',
            array(
                'taxonomy' => 'integrante_category',
                'field'    => 'slug',
                'terms'    => array( 'equipe_fundador','equipe_financas' )

            ),
        ),
    );
    $query = new WP_Query( $args );
    while ( $query->have_posts() ) : $query->the_post();
?>

<li>
  <h3 class="nome"><?php the_title(); ?></h3>
</li>

<?php endwhile; wp_reset_query();?>
</ul>

It returns all posts from the two taxonomies that I put. However, I need it to include a division ( title ) between one taxonomy and another, so it would have the mark from where the loop of each one begins.     

asked by anonymous 03.02.2016 / 18:01

1 answer

1

Make a category loop where you insert the category header, within that loop you will get the ids of all categories, use this to loop more posts, thus creating a pair of nested loops, avoiding having to use 10 different loops.

I'll coddle something here for you

    
12.04.2016 / 15:09