title: How to get latest three posts from the same category?
body: <p>I'm creating a new Website with WordPress and PHP. I'd need to get the latest three posts from the same category of the post I'm currently on. In addition, I need to avoid that the post I'm watching goes into the list of the three posts.</p>
  
  <p>I tried the code below so at the moment I just can display the name of three posts even though they ae not of same category...</p>
  
  <pre><code>&lt;?php
  $args = array( 'numberposts' =&gt; 3 );
  $lastposts = get_posts( $args );
  foreach($lastposts as $post) : setup_postdata($post); ?&gt;
  &lt;h2&gt;&lt;a href="&lt;?php the_permalink(); ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;      
  &lt;/h2&gt;
  &lt;?php endforeach; ?&gt;
  </code></pre>
  
  <p>I except the three latest posts to be of the same category of the website page.</p>