title: WordPress sidebar: make custom loop display posts in same category as single post, EXCLUDING current single post from the list
body: <p>This is from a sidebar set up to display 10 recent posts from the same category as the current single post being viewed. Unfortunately, it also includes the title and excerpt of the current single post in the list. </p>
  
  <p>Does anyone know how to change it so it EXCLUDES the current single post? Other than that, it works fine.</p>
  
  <pre><code>&lt;?php
  $query = "showposts=10&amp;orderby=date&amp;cat=";
  
  foreach((get_the_category()) as $category)
  { 
      $query .= $category-&gt;cat_ID .","; 
  }
  
  query_posts($query);
  ?&gt;
  
  &lt;ul&gt;
      &lt;?php while (have_posts()) : the_post(); ?&gt;
      &lt;li&gt;&lt;a href="&lt;?php the_permalink() ?&gt;" rel="bookmark" title="Permanent Link to &lt;?php the_title_attribute(); ?&gt;"&gt;&lt;?php the_title() ?&gt;&lt;/a&gt;
      &lt;?php the_excerpt(); ?&gt;
      &lt;/li&gt;
  
  &lt;?php endwhile; ?&gt;       
  
  &lt;/ul&gt;
  </code></pre>