Last active
June 22, 2020 11:54
-
-
Save mvaneijgen/ab78208375e9fb668d4a1df214f0bc9b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$taxonamy = 'location'; | |
$terms = get_terms($taxonamy, array('hide_empty' => true)); | |
?> | |
<?php if (!empty($terms) && !is_wp_error($terms)) : ?> | |
<?php foreach ($terms as $term) : ?> | |
<?php | |
$args = array( | |
'post_type' => 'thanks', | |
'posts_per_page' => -1, | |
'tax_query' => array( | |
'relation' => 'AND', | |
array( | |
'taxonomy' => 'type', | |
'field' => 'term_id', | |
'terms' => 13, | |
), | |
array( | |
'taxonomy' => $taxonamy, | |
'field' => 'slug', | |
'terms' => $term->slug, | |
), | |
) | |
); | |
$loop = new WP_Query($args); ?> | |
<?php if ($loop->have_posts()) : ?> | |
<h3><?php echo $term->name; ?></h3> | |
<div class="items"> | |
<?php while ($loop->have_posts()) : $loop->the_post(); ?> | |
<?php get_template_part('templates/content', get_post_type()); ?> | |
<?php endwhile; ?> | |
</div> | |
<?php endif; ?> | |
<?php wp_reset_postdata(); ?> | |
<?php endforeach; ?> | |
<?php endif; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment