
Posts grouped by tag
By: a guest on
May 13th, 2010 | syntax:
PHP | size: 0.59 KB | hits: 360 | expires: Never
<?php
// get the tag list
$taglist = get_terms('post_tag', 'hierarchical=0&orderby=name&hide_empty=1');
foreach ($taglist as $pftag) // iterate through the tag list
{
// get 2 posts belonging to the tag -- ONLY the slug works to filter by tag
query_posts('tag='.$pftag->slug.'&posts_per_page=2&orderby=date');?>
<!-- make a linked heading with the tag name -->
<h3><a href="/tag/<?php echo($pftag->slug); ?>"><?php echo($pftag->name); ?></a></h3>
<!-- make loop using custom action for output -->
<?php while (have_posts()) : the_post();
purplefrog_excerpt_tile();
endwhile;
} ?>