Created
September 26, 2013 12:21
-
-
Save rezzz-dev/6713387 to your computer and use it in GitHub Desktop.
Snippet: WP: List Custom Post Type Group By Taxonomy
This file contains hidden or 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 | |
$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 } ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for this!