Posted By

ignacio on 03/07/10


Tagged

wordpress tags


Versions (?)

WordPress : Posts by Tag (all tags considered)


 / Published in: PHP
 

  1. <?php
  2. $alltags = get_terms('post_tag');
  3. if ($alltags){
  4. //echo "<pre>"; print_r($alltags); echo "</pre>";
  5. foreach( $alltags as $tag ) {
  6. $args=array(
  7. 'tag__in' => array($tag->term_id),
  8. 'post_type' => 'post',
  9. 'post_status' => 'publish',
  10. 'showposts' => -1,
  11. 'caller_get_posts'=> 1
  12. );
  13. $my_query = null;
  14. $my_query = new WP_Query($args);
  15. if( $my_query->have_posts() ) {
  16. echo 'List of Posts in tag '.$tag->name;
  17. while ($my_query->have_posts()) : $my_query->the_post(); ?>
  18. <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
  19. <?php
  20. endwhile;
  21. }
  22. }
  23. }
  24. wp_reset_query(); // Restore global post data stomped by the_post().
  25. ?>

Report this snippet  

You need to login to post a comment.