Advertisement
alchymyth

tag related posts

Aug 28th, 2011
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.45 KB | None | 0 0
  1. global $post;
  2. $current_post = $post->ID;
  3.  
  4. $posttags = get_the_tags();
  5. if ($posttags) {  
  6.     foreach($posttags as $tag) {    
  7.         $tag = $tag->slug;  break;  
  8.     }
  9. $args = array(
  10. 'post__not_in' => array( $current_post ),
  11. 'tag' => $tag,
  12. 'posts_per_page' => -1);
  13. query_posts( $args );      
  14.     while (have_posts()) : the_post(); ?>      
  15.     <p><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></p>  
  16.     <?php endwhile;  
  17.     wp_reset_query();  
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement