Return to Snippet

Revision: 24647
at March 7, 2010 15:25 by ignacio


Initial Code
<?php
$alltags = get_terms('post_tag');
if ($alltags){
//echo "<pre>"; print_r($alltags); echo "</pre>";
  foreach( $alltags as $tag ) {
    $args=array(
      'tag__in' => array($tag->term_id),
      'post_type' => 'post',
      'post_status' => 'publish',
      'showposts' => -1,
      'caller_get_posts'=> 1
      );
    $my_query = null;
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {
      echo 'List of Posts in tag '.$tag->name;
      while ($my_query->have_posts()) : $my_query->the_post(); ?>
        <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
       <?php
      endwhile;
    }
  }
}
wp_reset_query();  // Restore global post data stomped by the_post().
?>

Initial URL


Initial Description


Initial Title
WordPress : Posts by Tag (all tags considered)

Initial Tags
wordpress

Initial Language
PHP