Answers.Body: <p>The reason <a href="http://buildwithcraft.com/docs/templating/craft.entries#limit"><code>limit()</code></a> isn't working is that is a method on the <a href="http://buildwithcraft.com/docs/templating/elementcriteriamodel"><code>ElementCriteriaModel</code></a> you get from <a href="http://buildwithcraft.com/docs/templating/craft.entries"><code>craft.entries</code></a>. </p>
  
  <p>Because you're actually dealing with a standard array when you access <code>catEntries</code>, what you want instead is Twig's <a href="http://twig.sensiolabs.org/doc/filters/slice.html"><code>|slice(start, length)</code></a> filter:</p>
  
  <pre><code>{% for entry in catEntries|slice(0, 4) %}
  
     // You'll only get four entries shown here
  
  {% endfor %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-28T20:52:28.480Z
Answers.Text: Worth mentioning, there is a shorthand for the `slice` filter... `catEntries[0:4]`
Answers.UserDisplayName: Lindsey D
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-12-04T02:46:08.743Z
Answers.Text: This worked flawlessly. Now I'm wondering if there's a way to order the categories that are returned, entries can come in any order, but I'd like my categories to output in a particular one here?
Answers.UserDisplayName: brandongcarroll
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-28T15:09:45.727Z
Answers.LastActivityDate: 2014-11-28T15:09:45.727Z
Answers.UserDisplayName: Mike Pepper
Body: <p>I'm wondering how I would go about limiting the number of results returned from a set using the group filter? I only want four to show, but using the <code>limit()</code> method seems to throw errors wherever I put it. Here's my template code:</p>
  
  <pre><code>{% set entries = craft.entries.section('recipes').find() %}
  
  {% for category, catEntries in entries | group('cuisineType.first().title') %}
  
      {% for entry in catEntries %}
  
         // I only want four entries shown here
  
      {% endfor %}
  
  {% endfor %}
  </code></pre>
  
Tags: <templating><filter><category><limit>
Title: How to limit number of entries returned from a group filter?
ThreadText: # How to limit number of entries returned from a group filter?
  
  (Asked by: username_0 on 2014-11-28)
  
  I'm wondering how I would go about limiting the number of results returned from a set using the group filter? I only want four to show, but using the `limit()` method seems to throw errors wherever I put it. Here's my template code:
  
  ```
  {% set entries = craft.entries.section('recipes').find() %}
  
  {% for category, catEntries in entries | group('cuisineType.first().title') %}
  
      {% for entry in catEntries %}
  
         // I only want four entries shown here
  
      {% endfor %}
  
  {% endfor %}
  
  ```
  
  **Tags:** templating, filter, category, limit
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2014-11-28. Score: 5
  
  The reason [`limit()`](http://buildwithcraft.com/docs/templating/craft.entries#limit) isn't working is that is a method on the [`ElementCriteriaModel`](http://buildwithcraft.com/docs/templating/elementcriteriamodel) you get from [`craft.entries`](http://buildwithcraft.com/docs/templating/craft.entries).
  
  Because you're actually dealing with a standard array when you access `catEntries`, what you want instead is Twig's [`|slice(start, length)`](http://twig.sensiolabs.org/doc/filters/slice.html) filter:
  
  ```
  {% for entry in catEntries|slice(0, 4) %}
  
     // You'll only get four entries shown here
  
  {% endfor %}
  
  ```
  
  > **Comments:**
  > **username_2**: Worth mentioning, there is a shorthand for the `slice` filter... `catEntries[0:4]`  
  > **username_0**: This worked flawlessly. Now I'm wondering if there's a way to order the categories that are returned, entries can come in any order, but I'd like my categories to output in a particular one here?  
  
  ---
  
  