Custom Post Type Archive Posts Ordered by Term
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 | |
/* 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