Skip to content

Instantly share code, notes, and snippets.

@joshfeck
Created April 14, 2017 16:19
Show Gist options
  • Save joshfeck/3e2327997531609e65bd51f01abf6e13 to your computer and use it in GitHub Desktop.
Save joshfeck/3e2327997531609e65bd51f01abf6e13 to your computer and use it in GitHub Desktop.
Custom loop for the Event Espresso people add-on that loops through each people type taxonomy term and displays the people that are set for that term
<?php
$post_type = 'espresso_people';
$taxonomy = 'espresso_people_type';
$terms = get_terms( array(
'taxonomy'=>$taxonomy,
'orderby'=>'name',
'order'=>'DESC',
));
foreach( $terms as $term ) :
?>
<h2><?php echo $term->name; ?></h2>
<ul>
<?php
$posts = get_posts(array(
'post_type'=>$post_type,
'suppress_filters'=>false,
'tax_query'=>array(
array(
'taxonomy'=>$taxonomy,
'field'=>'slug',
'terms'=>$term
)
)
)
);
foreach( $posts as $post ) :
?>
<li>
<?php the_title();?>
</li>
<?php
endforeach;
?> </ul> <?php
endforeach;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment