Skip to content

Instantly share code, notes, and snippets.

@rezzz-dev
Created September 26, 2013 12:21
Show Gist options
  • Save rezzz-dev/6713387 to your computer and use it in GitHub Desktop.
Save rezzz-dev/6713387 to your computer and use it in GitHub Desktop.
Snippet: WP: List Custom Post Type Group By Taxonomy
<?php
$attractions = get_terms('attraction', array("fields" => "names"));
for ( $myterm = 0; $myterm < count($attractions); $myterm++) { ?>
<h3><?php echo $attractions[$myterm]; ?>:</h3>
<div class="taxonomy_group">
<?php $loop = new WP_Query(array('attraction' => $attractions[$myterm]));
while ( $loop->have_posts() ) : $loop->the_post();
get_template_part( 'content', 'things-to-do' );
endwhile; ?>
</div>
<?php } ?>
@FriendlyWP
Copy link

Thank you for this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment