<p><a href="http://buildwithcraft.com/docs/templating/craft.entries">craft.entries()</a> fetches entries.</p>

<p>To fetch the entries with a given entry type, you use <a href="http://buildwithcraft.com/docs/templating/craft.entries#type">type</a>. So to get the <em>Article</em> entries, either <code>craft.entries.type('Article')</code> or <code>craft.entries({type: 'Article'})</code></p>

<p>To fetch the latest 5, you want the entries <a href="http://buildwithcraft.com/docs/templating/craft.entries#order">sorted</a> by postDate, descending (this is the default sort order), and then <a href="http://buildwithcraft.com/docs/templating/craft.entries#limit">limit</a> that to 5. Combining with the entry type, you have: <code>craft.entries.type('Article').limit(5)</code> or <code>craft.entries({type: 'Article', limit: 5})</code></p>

<p>And you have four entry types, so might as well loop over those:</p>

<pre><code>{% for entryType in ['Article', 'Video', 'Photo', Quote] %}
  {% set latestFive = craft.entries({
    type: entryType,
    limit: 5
  }) %}

  {% for oneEntry in latestFive %}
    {# list that entry #}
    {{ oneEntry.title}} is of type {{ entryType }}
  {% endfor %}

{% endfor %}
</code></pre>

CC BY-SA 3.0
2014-07-20T21:40:15.450Z
2014-07-20T21:40:15.450Z
Marion Newlevant
<p>Let's say I have 4 entry types (Article, Video, Photo &amp; Quote). What's the best way to list the latest 5 entries by each entry type?</p>

<entries><entry-type>
How to list the latest 5 entries per entry type?
# How to list the latest 5 entries per entry type?

(Asked by: username_0 on 2014-07-20)

Let's say I have 4 entry types (Article, Video, Photo & Quote). What's the best way to list the latest 5 entries by each entry type?

**Tags:** entries, entry-type


---

## 1 answers

### Answer by username_1 on 2014-07-20. Score: 8

craft.entries() fetches entries.
To fetch the entries with a given entry type, you use type. So to get the Article entries, either craft.entries.type('Article') or craft.entries({type: 'Article'})
To fetch the latest 5, you want the entries sorted by postDate, descending (this is the default sort order), and then limit that to 5. Combining with the entry type, you have: craft.entries.type('Article').limit(5) or craft.entries({type: 'Article', limit: 5})
And you have four entry types, so might as well loop over those:
{% for entryType in ['Article', 'Video', 'Photo', Quote] %}
  {% set latestFive = craft.entries({
    type: entryType,
    limit: 5
  }) %}

  {% for oneEntry in latestFive %}
    {# list that entry #}
    {{ oneEntry.title}} is of type {{ entryType }}
  {% endfor %}

{% endfor %}


---

