Skip to content

Instantly share code, notes, and snippets.

@mbijon
Created January 30, 2013 11:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbijon/4672506 to your computer and use it in GitHub Desktop.
Save mbijon/4672506 to your computer and use it in GitHub Desktop.
WordPress taxonomy archive loop for Amanda CORRECT: while ( $sushi_group_query->have_posts() ) : $sushi_group_query->the_post(); OLD: while ( $sushi_group_query->have_posts() ) : the_post();
<?php
global $wp_query;
$sushi_group_terms = get_terms( 'Sushi Type' );
foreach ( $sushi_group_terms as $sushi_group_term ) {
$taxonomy_term = $sushi_group_term->slug;
$sushi_group_query = new WP_Query( array(
'post_type' => 'sushi',
'tax_query' => array(
array(
'taxonomy' => 'Sushi Type',
'field' => 'slug',
'terms' => $taxonomy_term,
'operator' => 'IN'
)
)
) );
?>
<h2><?php echo $sushi_group_term->name; ?></h2>
<ul>
<?php
if ( $sushi_group_query->have_posts() ) :
while ( $sushi_group_query->have_posts() ) :
$sushi_group_query->the_post();
the_title( '<li>', '</li>' );
endwhile;
endif;
?>
</ul>
<?php
// Reset things, for good measure
$sushi_group_query = null;
wp_reset_postdata();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment