You are viewing an old revision of this post, from September 20, 2013 @ 00:28:46. See below for differences between this version and the current revision.

Query Posts with a taxonomy and group them by term

[php]<?php $terms = get_terms("taxonomy"); $count = count($terms); if ( $count > 0 ){ foreach ( $terms as $term ) { ?> <div class="block"> <h3 class="title"><?php echo $term->name; ?></h3> <div class="content"> <?php $sticky=get_option('sticky_posts'); $args = array( 'taxonomy'=> $term->slug, 'posts_per_page'=>-1, 'post__not_in' => $sticky ); query_posts($args); if (have_posts()) : while (have_posts()) : the_post(); ?> <div class="item"> <h2 class="post-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> <p><?php the_excerpt(); ?><a href="<?php the_permalink(); ?>">Keep reading</a></p> </div><!--item--> <?php endwhile; endif; ?> </div><!--cont--> </div><!--block--> <?php } } ?>[/php]

Revisions

  • September 20, 2013 @ 00:28:46 [Current Revision] by PeterLugg
  • September 20, 2013 @ 00:28:46 by PeterLugg

Revision Differences

There are no differences between the September 20, 2013 @ 00:28:46 revision and the current revision. (Maybe only post meta information was changed.)

Tags:

No comments yet.

Leave a Reply