Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Kevin

By: a guest on Jan 13th, 2011  |  syntax: None  |  size: 1.00 KB  |  views: 71  |  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 all terms (e.g. categories or post tags), then display all posts in each term
  3. $taxonomy = 'post_tag';//  e.g. post_tag, category
  4. $param_type = 'tag__in'; //  e.g. tag__in, category__in
  5. $term_args=array(
  6.   'include' => '356',
  7.   'orderby' => 'count',
  8.   'order' => 'ASC'
  9. );
  10. $terms = get_terms($taxonomy,$term_args);
  11. if ($terms) {
  12.   foreach( $terms as $term ) {
  13.     $args=array(
  14.       "$param_type" => array($term->term_id),
  15.       'post_type' => 'post',
  16.       'post_status' => 'publish',
  17.       'posts_per_page' => -1,
  18.       'caller_get_posts'=> 1
  19.       );
  20.     $my_query = null;
  21.     $my_query = new WP_Query($args);
  22.     if( $my_query->have_posts() ) {
  23.       while ($my_query->have_posts()) : $my_query->the_post(); ?>
  24.         <li><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
  25.        <?php
  26.       endwhile;
  27.     }
  28.   }
  29. }
  30. wp_reset_query();  // Restore global post data stomped by the_post().
  31. ?>