title: Show last 5 posts from specific category (Wordpress)
body: <p>I'm trying to show the last 5 posts from a specific category, which will be linked to a function so I can insert the shortcode in a Wordpress page. The code I have is as below, it does everything I need (although I want to add featured image too) except it does not show posts from a specific category.</p>
  
  <p>I've tried numerous things, but cannot find a working fix.</p>
  
  <pre><code>function Last5posts()
  {
      $args = array( "showposts" =&gt; 5, "category" =&gt; 3 ); 
      $content = "";   
  
      query_posts($args);
  
      if ( have_posts() ) : 
  
          while ( have_posts() ) :
              the_post();
  
              $link = get_permalink();
              $title = get_the_title();
              $date = get_the_date();                              
  
              $content .= "&lt;div class='latest-posts'&gt;";
              $content .= "&lt;h3&gt;&lt;a href='$link' target='_top'&gt;$title / $date&lt;/a &lt;/h3&gt;\n";
              $content .= "&lt;p class='excerpt'&gt;" . get_the_excerpt() . "&lt;/p&gt;";
              $content .= "&lt;/div&gt;";
  
          endwhile;
  
          wp_reset_query(); 
  
       endif;
  
       return $content;
  }
  
  add_shortcode('Last5Posts', 'Last5posts' );   
  </code></pre>
  
  <p>I have tried replacing lines 3 and 4 with the code below, but it throws an error "syntax error, unexpected '}' on line 31".</p>
  
  <pre><code>$catquery = new WP_Query( 'cat=3&amp;posts_per_page=10' );
  while($catquery-&gt;have_posts()) : $catquery-&gt;the_post(); 
  </code></pre>
  
  <p>Any help would be greatly appreciated.</p>