title: How can I display only two posts from each category in wordpress?
body: <p>I have to display 2 posts from each category. The code below gets all the posts belong to each category. My structure is tab based. I am attaching the image of my design. My tabs contain "all (shows all posts)", "symptoms (shows posts related to symptoms only" etc. ,clicking on each tabs shows relevant posts.
   <a href="https://i.stack.imgur.com/NVXeE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NVXeE.png" alt="enter image description here"></a>       </p>
  
  <pre><code> &lt;?php $recent = new WP_Query("post_type=post&amp;posts_per_page=-1&amp;orderby=date&amp;order=DESC");
                  $count=0;                         
                      $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
                      while($recent-&gt;have_posts()) : $recent-&gt;the_post(); ?&gt;
                      &lt;?php $c = get_the_category();
                      $cat =  $c[0]-&gt;cat_name;
                      $slug = $c[0]-&gt;category_nicename;
                      ?&gt;
                      &lt;div class="element-item transition &lt;?php echo $slug;?&gt;" data-category="&lt;?php echo $slug;?&gt;"&gt;
                          &lt;a href="&lt;?php the_permalink(); ?&gt;" title="&lt;?php the_title(); ?&gt;"&gt;
                              &lt;div class="descrip"&gt;
                                  &lt;h2&gt;&lt;?php the_title(); ?&gt;&lt;/h2&gt;
                               &lt;/div&gt;
                          &lt;/a&gt;
                      &lt;/div&gt;
                  &lt;?php endwhile; wp_reset_postdata(); ?&gt; 
  </code></pre>
  
  <p>[![enter image description here][2]][2]</p>
  
  <p>Any help would be appreciated</p>