title: Wordpress Querying Related Posts by tag
body: <p>I am trying to query a list of posts with the same tags as the current post being viewed in WordPress. I thought that if I could query the list of tags for the current post, pass it into a variable and then pass that variable into query_posts argument it would get the job done. It seems to work for one of the tags in the post but I am clearly doing something wrong. Here is a sample of the code I have written thus far:</p>
  
  <pre><code>&lt;?php
  $posttags = get_the_tags();
  if ($posttags) {
  foreach($posttags as $tag) {
      $test = ',' . $tag-&gt;name; 
  }
  }
  query_posts('tag=' .$test . '&amp;showposts=-1'); while (have_posts()) : the_post(); ?&gt;
        &lt;p&gt;&lt;a href="&lt;?php the_permalink(); ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/p&gt;
  &lt;?php endwhile; wp_reset_query(); ?&gt;
  </code></pre>
  
  <p>Any clarification on what I'm doing wrong would be very much appreciated.</p>