<p>Here's how I've gone about that in the past.</p>

<p>Loop through all sections, and only if section.type is structure and doesn't have the handle 'pages' (skip that section, essentially);</p>

<pre><code>{% for section in craft.sections.getAllSections() if section.type == 'structure' and section.handle != 'pages' %}
  What you want to do here... Print the content or whatnot.
{% endfor %}
</code></pre>

<p>And if you only want to get channels;</p>

<pre><code>{% for section in craft.sections.getAllSections() if section.type == 'channel' %}
  What you want to do with the channels here...
{% endfor %}
</code></pre>

CC BY-SA 3.0
2016-11-17T22:16:27.177Z
2016-11-17T22:23:03.373Z
2016-11-17T22:23:03.373Z
Anders
<p>I'm looping over my sections to produce a section filter group. But I want to exclude at least 2 of the sections. </p>

<p>I'd have thought I could do <code>craft.sections.getAllSections('not 18')</code> for example but it seems not.</p>

<p>What's best approach?</p>

<sections><conditional>
getAllSections but not these specific sections
# getAllSections but not these specific sections

(Asked by: username_0 on 2016-11-17)

I'm looping over my sections to produce a section filter group. But I want to exclude at least 2 of the sections.

I'd have thought I could do `craft.sections.getAllSections('not 18')` for example but it seems not.

What's best approach?

**Tags:** sections, conditional


---

## 1 answers

### Answer by username_1 on 2016-11-17. Score: 1

Here's how I've gone about that in the past.
Loop through all sections, and only if section.type is structure and doesn't have the handle 'pages' (skip that section, essentially);
{% for section in craft.sections.getAllSections() if section.type == 'structure' and section.handle != 'pages' %}
  What you want to do here... Print the content or whatnot.
{% endfor %}

And if you only want to get channels;
{% for section in craft.sections.getAllSections() if section.type == 'channel' %}
  What you want to do with the channels here...
{% endfor %}


---

