Answers.Body: <p>You're close – this should work in Craft 3.x and 4.x (look at @obs answer for Craft 5):</p>
  <pre><code>{% set blogSection = craft.app.sections.getSectionByHandle('blog') %}
  {% set blogSectionEntryTypes = blogSection.getEntryTypes() %}
  
  {% for entryType in blogSectionEntryTypes %}
      &lt;p&gt;{{ entryType.name }}&lt;/p&gt;
  {% endfor %}
  </code></pre>
  <p>The reason why <code>craft.entries.section('blog').getEntryTypes()</code> didn't work is that <code>craft.entries</code> will actually create an <a href="https://docs.craftcms.com/v3/dev/element-queries/" rel="nofollow noreferrer">ElementQuery</a>, which is used to query for elements (e.g. entries).</p>
  <p>When you use <code>craft.app.sections</code> or <code>craft.app.getSections()</code> (it doesn't really matter which variant you use, although the latter is a micro-optimisation in terms of performance) you're interacting with the <a href="https://docs.craftcms.com/api/v3/craft-services-sections.html" rel="nofollow noreferrer">Sections service</a>, which is what you need to use to work with sections and their entry types directly, rather than entries.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-10-02T12:50:54.833Z
Answers.Text: Thank you very much for the solution and for the explanation! I'll read up some more on how Craft works, particularly the parts you've mentioned.
Answers.UserDisplayName: Ryan Roberts
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-09-10T12:37:57.253Z
Answers.Text: How can the resulting list of entry types be sorted? I'm having no luck in Craft 4 using the `|sort` filter on these things.
Answers.UserDisplayName: Sandwich
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-10-02T12:25:41.843Z
Answers.LastActivityDate: 2024-04-29T14:24:31.190Z
Answers.LastEditDate: 2024-04-29T14:24:31.190Z
Answers.UserDisplayName: Mats Mikkel Rummelhoff
Answers.Body: <p>For anyone coming here and looking for a solution for Craft 5:</p>
  <p>It now works like that:</p>
  <pre><code>{% set section = craft.app.entries.getSectionByHandle('blog') %}
  {% set entryTypes = craft.app.entries.getEntryTypesBySectionId( section.id ) %}
  </code></pre>
  <p>Here are the docs: <a href="https://docs.craftcms.com/api/v5/craft-services-entries.html#entries" rel="nofollow noreferrer">https://docs.craftcms.com/api/v5/craft-services-entries.html#entries</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-04-27T19:29:17.200Z
Answers.LastActivityDate: 2024-04-27T19:29:17.200Z
Answers.UserDisplayName: obs
Body: <p>The following outputs all sections and their entry types, but I'm struggling to work out how I output only the entry types from the "blog" section.</p>
  
  <pre><code>{% for section in craft.app.sections.allSections() %}
    &lt;h2&gt;{{ section.name }}&lt;/h2&gt;
  
    &lt;ul&gt;
      {% for type in section.getEntryTypes() %}
        &lt;li&gt;{{ type.name }}&lt;/li&gt;
      {% endfor %}
    &lt;/ul&gt;
  {% endfor %}
  </code></pre>
  
  <p>I thought this would work</p>
  
  <pre><code>{% for type in craft.entries.section('blog').getEntryTypes() %}
    &lt;p&gt;{{ type.name }}&lt;/li&gt;
  {% endfor %}
  </code></pre>
  
  <p>But I've hit a wall because <code>getEntryTypes()</code> is an unknown method.</p>
  
Tags: <templating><craft3><sections><entry-type>
Title: How can I list Entry Types of a single Section?
ThreadText: # How can I list Entry Types of a single Section?
  
  (Asked by: username_0 on 2018-10-02)
  
  The following outputs all sections and their entry types, but I'm struggling to work out how I output only the entry types from the "blog" section.
  
  ```
  {% for section in craft.app.sections.allSections() %}
    <h2>{{ section.name }}</h2>
  
    <ul>
      {% for type in section.getEntryTypes() %}
        <li>{{ type.name }}</li>
      {% endfor %}
    </ul>
  {% endfor %}
  
  ```
  
  I thought this would work
  
  ```
  {% for type in craft.entries.section('blog').getEntryTypes() %}
    <p>{{ type.name }}</li>
  {% endfor %}
  
  ```
  
  But I've hit a wall because `getEntryTypes()` is an unknown method.
  
  **Tags:** templating, craft3, sections, entry-type
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2018-10-02. Score: 3 | Accepted answer
  
  You're close – this should work in Craft 3.x and 4.x (look at @username_3 answer for Craft 5):
  
  ```
  {% set blogSection = craft.app.sections.getSectionByHandle('blog') %}
  {% set blogSectionEntryTypes = blogSection.getEntryTypes() %}
  
  {% for entryType in blogSectionEntryTypes %}
      <p>{{ entryType.name }}</p>
  {% endfor %}
  
  ```
  
  The reason why `craft.entries.section('blog').getEntryTypes()` didn't work is that `craft.entries` will actually create an [ElementQuery](https://docs.craftcms.com/v3/dev/element-queries/), which is used to query for elements (e.g. entries).
  
  When you use `craft.app.sections` or `craft.app.getSections()` (it doesn't really matter which variant you use, although the latter is a micro-optimisation in terms of performance) you're interacting with the [Sections service](https://docs.craftcms.com/api/v3/craft-services-sections.html), which is what you need to use to work with sections and their entry types directly, rather than entries.
  
  > **Comments:**
  > **username_0**: Thank you very much for the solution and for the explanation! I'll read up some more on how Craft works, particularly the parts you've mentioned.  
  > **username_2**: How can the resulting list of entry types be sorted? I'm having no luck in Craft 4 using the `|sort` filter on these things.  
  
  ---
  
  ### Answer by username_3 on 2024-04-27. Score: 4
  
  For anyone coming here and looking for a solution for Craft 5:
  
  It now works like that:
  
  ```
  {% set section = craft.app.entries.getSectionByHandle('blog') %}
  {% set entryTypes = craft.app.entries.getEntryTypesBySectionId( section.id ) %}
  
  ```
  
  Here are the docs: <https://docs.craftcms.com/api/v5/craft-services-entries.html#entries>
  
  
  ---
  
  