Created
January 30, 2013 11:10
-
-
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();
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 | |
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