Sign up ×
Craft CMS Stack Exchange is a question and answer site for administrators, end users, developers and designers for Craft CMS. It's 100% free, no registration required.

I have a 'teacher' channel section on my site. That channel has three entry types, 'teacher', 'demoTeacher' and 'guestTeacher' - how do I display entries from teacher and demoTeach combined? At the moment I'm showing one type like this:

{% for teacher in craft.entries.find({section: 'teacher', type: 'demoTeacher'}) %}

Secondly, how can I use a conditional that checks for entry type? I need do something like the following (pseudocode):

{% if entrytype is demoTeacher %}
    display read more button
{% endif %}
share|improve this question

2 Answers 2

up vote 4 down vote accepted

You can set the ElementCriteriaModel's type parameter to multiple values by passing it an array of entry type slugs:

{% set teachers = craft.entries.section('teacher').type(['teacher', 'demoTeacher']) %}

Use the type property on the entry model to access its entry type in your conditional (also see this list for other available properties).

{% for teacher in teachers %}

    {{ teacher.title }}

    {% if teacher.type == 'demoTeacher' %}
    {% endif %}

{% endfor %}
share|improve this answer
Thanks - that works. Any idea how to use a conditional to test for entry type? – Daryl Knight Sep 3 '14 at 22:06
Sure I have! :) – carlcs Sep 3 '14 at 22:08
Excellent - thanks matey :) – Daryl Knight Sep 3 '14 at 22:28

I know an answer has been accepted for this question, but I wanted to provide another example for folks like me who seem to have a thick skull sometimes.

I have a "team" section which is a structure (the entries within this structure do not have their own urls). Within that structure, I have two different entry types. "Team Category" and "Team Member". This allows me to nest different team members under different categories.

For example,

    - Bob Smith
    - John Doe

Here is how I did that in my entry template:

{% set teamMembers = craft.entries.section('team').type(['teamCategory', 'teamMember']) %}
    {% for member in teamMembers %}
        <div class="team-member">
        {% if member.type == 'teamCategory' %}
            <h3>{{ member.title }}</h3> {# Accounting #}
        {% else %}
            <p>{{ member.title }}</p>  {# Bob Smith #}
        {% endif %}
    {% endfor %}
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.