Terms and Displaying All Posts For Each

0
420
<?php * Template Name: Find a store   //make a page and you can call it admin section  
$_terms = get_terms( array('category-film') );

foreach ($_terms as $term) :

    $term_slug = $term->slug;
    $_posts = new WP_Query( array(
                'post_type'         => 'film',
                'posts_per_page'    => 10, //important for a PHP memory limit warning
                'tax_query' => array(
                    array(
                        'taxonomy' => 'category-film',
                        'field'    => 'slug',
                        'terms'    => $term_slug,
                    ),
                ),
            ));

    if( $_posts->have_posts() ) :

        echo '<h3>'. $term->name .'</h3>';
        while ( $_posts->have_posts() ) : $_posts->the_post();
        ?>
            <div class="col-md-6">
                <h4><?php the_title(); ?></h4>
                <p><?php get_post_meta( get_the_ID(), 'url', true ); ?></p>
            </div>
        <?php
        endwhile;

    endif;
    wp_reset_postdata();

endforeach;
?>