Skip to content

Instantly share code, notes, and snippets.

@wpmark
Last active August 29, 2015 14:23
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save wpmark/2dd9265f9e4d3316dc17 to your computer and use it in GitHub Desktop.
Custom Post Type Archive Posts Ordered by Term
<?php
/* get our array of post ids in term order */
$people = wpmark_get_posts_in_terms_array(
array(
'orderby' => 'id',
'taxonomy' => 'sdance_person_type',
'posts' => $wp_query->posts
)
);
/* loop through our people array */
foreach( $people as $term_name => $post_ids ) {
?>
<div class="<?php echo esc_attr( wpmark_counter_class( $person_type_class_args ) ); ?>">
<h2 class="person-type-title"><?php echo esc_html( $term_name ); ?></h2>
<div class="person-type-content">
<?php
/* loop through each of the posts in this term */
foreach( $post_ids as $post ) {
/* setup the post data - gives access to the_content etc. */
setup_postdata( $post );
/* output your post here- perhaps using get_template_part to show the content */
}
/* reset post data */
wp_reset_postdata();
?>
</div>
</div>
<?php
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment