Don't like ads? PRO users don't see any ads ;-)
Guest

Posts grouped by tag

By: a guest on May 13th, 2010  |  syntax: PHP  |  size: 0.59 KB  |  hits: 360  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2. // get the tag list
  3. $taglist = get_terms('post_tag', 'hierarchical=0&orderby=name&hide_empty=1');
  4. foreach ($taglist as $pftag) // iterate through the tag list
  5. {
  6.         // get 2 posts belonging to the tag -- ONLY the slug works to filter by tag
  7.         query_posts('tag='.$pftag->slug.'&posts_per_page=2&orderby=date');?>
  8.         <!-- make a linked heading with the tag name -->
  9.         <h3><a href="/tag/<?php echo($pftag->slug); ?>"><?php echo($pftag->name); ?></a></h3>
  10.         <!-- make loop using custom action for output -->
  11.         <?php while (have_posts()) : the_post();
  12.                 purplefrog_excerpt_tile();
  13.                 endwhile;
  14. } ?>