title: Show category by latest post date
body: <p>I am working in a project where I am using below code to limit number of posts in each category. But I can't figure out how to sort these categories by latest posts. My code is working fine but when I add argument in <strong>wp query array</strong>, it does not sort or it breaks. I want to order the category with most <strong>recent post (date).</strong></p>
  <p>Can anyone guide me?</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php $terms=g et_terms( array( 'taxonomy'=&gt;'category', 'hide_empty' =&gt; false, ) ); foreach($terms as $cat){ $cata_name = $cat-&gt;name; $term_id = $cat-&gt;term_id; ?&gt;
  &lt;?php //echo '&lt;h3&gt;'.$catname[0]-&gt;cat_name.'&lt;/h3&gt;'; ?&gt;
  &lt;?php $catqueryy=n ew WP_Query ( 'cat='.$term_id. '&amp;posts_per_page=5');$count=$ catqueryy-&gt;found_posts; ?&gt;</code></pre>
  </div>
  </div>
  </p>