title: how to limit the number of categories to be displayed in wordpress using custom template?
body: <p>My code in custom template is
    
  
  <pre><code>$categories = get_categories( array(
  'hide_empty'       =&gt; 0
  ) );
  
  foreach ($categories as $cat) : ?&gt;
  &lt;div class="fusion-one-third fusion-layout-column fusion-spacing-yes"&gt;
  
      &lt;a href="&lt;?php echo get_category_link($cat-&gt;term_id); ?&gt;"&gt;
          &lt;img src="&lt;?php echo z_taxonomy_image_url($cat-&gt;term_id); ?&gt;" /&gt;
          &lt;h1 class="customp"&gt;&lt;?php echo $cat-&gt;cat_name; ?&gt;&lt;/h1&gt;
      &lt;/a&gt;
  &lt;/div&gt;
  &lt;?php endforeach; ?&gt;
  </code></pre>
  
  <p>It is displaying every category created but I want to display only 6 latest categories. No matter if these categories have any posts or not.</p>