<p>Updating for Craft3 and calling for different types, I wanted to share how I use the entry types to create different header/slider entry.</p>
<pre><code>{% set slides = craft.entries().section('slider') %}
{% set entries = slides.all() %}
{% for entry in entries %}
    {% if entry.type == 'type1' %}
        {# Your content for 'type1' Entry here #}
    {% endif %}
    {% if entry.type == 'type2' %}
        {# Your content for 'type2' Entry here #}
    {% endif %}
    {% if entry.type == 'type3' %}
        {# Your content for 'type3' Entry here #}
    {% endif %}
{% endfor %} 
</code></pre>

CC BY-SA 4.0
2020-10-12T00:15:19.427Z
2020-10-12T00:15:19.427Z
Cynder Gray
<pre><code>{% set entries = craft.entries.section('pages').type('blogPost') %}

{% for entry in entries %}
   {{ entry.title }}
{% endfor %}
</code></pre>

<p>Is what I have cobbled together... any pointers on improvements would be welcome.</p>

CC BY-SA 3.0
2014-07-05T13:32:11.737Z
That's exactly how to do it!
Brad Bell
CC BY-SA 3.0
2014-07-05T19:43:04.367Z
Cheers Brad much appreciated.
bobbyballbags
CC BY-SA 3.0
2014-07-05T10:19:04.667Z
2014-07-05T13:31:51.233Z
2014-07-05T13:31:51.233Z
bobbyballbags
<p>I would like to loop through entries in a channel but only the ones for a specific entry type. Is this Possible?</p>

<p>I'm using the free version of craft on a test site, I have used the channel for my pages but also want to set up a blog. I have set up a blogPost entry type, is there a way to target this in a loop?</p>

<entry-type><loop><forloop>
How do I loop through entries for a specific entry type?
# How do I loop through entries for a specific entry type?

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

I would like to loop through entries in a channel but only the ones for a specific entry type. Is this Possible?

I'm using the free version of craft on a test site, I have used the channel for my pages but also want to set up a blog. I have set up a blogPost entry type, is there a way to target this in a loop?

**Tags:** entry-type, loop, forloop

---

## 2 answers

### Answer by username_0 on 2014-07-05. Score: 14 | Accepted answer

{% set entries = craft.entries.section('pages').type('blogPost') %}

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

Is what I have cobbled together... any pointers on improvements would be welcome.

> **Comments:**
> **username_2**: That's exactly how to do it!  
> **username_0**: Cheers Brad much appreciated.  

---

### Answer by username_1 on 2020-10-12. Score: 1

Updating for Craft3 and calling for different types, I wanted to share how I use the entry types to create different header/slider entry.
{% set slides = craft.entries().section('slider') %}
{% set entries = slides.all() %}
{% for entry in entries %}
    {% if entry.type == 'type1' %}
        {# Your content for 'type1' Entry here #}
    {% endif %}
    {% if entry.type == 'type2' %}
        {# Your content for 'type2' Entry here #}
    {% endif %}
    {% if entry.type == 'type3' %}
        {# Your content for 'type3' Entry here #}
    {% endif %}
{% endfor %}


---

