<p>Try using the <a href="https://craftcms.com/docs/templating/filters#group" rel="nofollow noreferrer">group filter</a></p>

<pre><code>{% set entries = craft.entries.search(query).order('score') %}

{% for sectionName, sectionEntries in entries | group('section.name') %}
    &lt;h2&gt;{{ sectionName }}&lt;/h2&gt;

    &lt;ul&gt;
        {% for entry in sectionEntries %}
            &lt;li&gt;{{ entry.title }}&lt;/li&gt;
        {% endfor %}
    &lt;/ul&gt;
{% endfor %}
</code></pre>

CC BY-SA 3.0
2017-10-25T20:48:20.977Z
2017-10-25T20:48:20.977Z
Trevor Davis
<p>I have a set of entries from multiple channels and I want to loop through each section type that is in the set.</p>

<p>Something like </p>

<pre><code>{% set entries = craft.entries.search(query).order('score') %}

{% for entrySection in entries.sections %}
    {{ entrySection.name }}
{% endfor %}
</code></pre>

<p>So basically if I have 100 results from across 8 sections, is there a way I can list out those 8 sections separately?</p>

<entries><sections>
In a large set of entries across multiple sections, how can I loop through each section type in the set?
# In a large set of entries across multiple sections, how can I loop through each section type in the set?

(Asked by: username_0 on 2017-10-25)

I have a set of entries from multiple channels and I want to loop through each section type that is in the set.
Something like 
{% set entries = craft.entries.search(query).order('score') %}

{% for entrySection in entries.sections %}
    {{ entrySection.name }}
{% endfor %}

So basically if I have 100 results from across 8 sections, is there a way I can list out those 8 sections separately?

**Tags:** entries, sections

---

## 1 answers

### Answer by username_1 on 2017-10-25. Score: 2 | Accepted answer

Try using the group filter
{% set entries = craft.entries.search(query).order('score') %}

{% for sectionName, sectionEntries in entries | group('section.name') %}
    {{ sectionName }}

    
        {% for entry in sectionEntries %}
            {{ entry.title }}
        {% endfor %}
    
{% endfor %}


---

