Answers.Body: <p>This has nothing specifically to do with the question, but this post was very helpful in figuring out how to get all entries that are <strong>channels</strong>. Just wanted to share in case someone else came across this thread. This will return all entries for every channel.</p>
  
  <pre><code>{% set sections = craft.sections.getAllSections() %}
  {% for channelSection in sections if channelSection.type == 'channel' %}  
  
      {% set channelEntry = craft.entries.sectionId(channelSection.id) %}
          {% for entry in channelEntry %}
              &lt;div class="block {{ channelSection.handle }}"&gt;
                  &lt;div class="block-header"&gt;
                      &lt;h4&gt;&lt;a href="{{ entry.url }}"&gt;{{ entry.title }}&lt;/a&gt;&lt;/h4&gt;
                  &lt;/div&gt;
                  &lt;div class="block-summary"&gt;
                      {{ entry.summary }}
                      &lt;p&gt;
                          &lt;small&gt;(In {{ channelSection }})&lt;/small&gt;
                      &lt;/p&gt;
                  &lt;/div&gt;
                  &lt;div class="block-footer text-right"&gt;
                      &lt;i class="fa fa-ellipsis-h"&gt;&lt;/i&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          {% endfor %}
  
  {% endfor %}
  </code></pre>
  
  <p>As you can see I am using:</p>
  
  <pre><code>{{ channelSection.handle }}
  </code></pre>
  
  <p>To generate something like <code>myChannelHandle</code> which (could) is useful for creating hooks for css/js.</p>
  
  <p>Hope this helps!</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-21T22:27:45.927Z
Answers.LastActivityDate: 2015-07-21T22:27:45.927Z
Answers.UserDisplayName: Damon
Answers.Body: <p>There's no such method available for <code>craft.entries</code>, at least it's not documented. But you can use <a href="http://buildwithcraft.com/docs/templating/craft.sections"><code>craft.sections</code></a> to get an array of section models and filter them with a conditional within a loop:</p>
  
  <pre><code>{# Get all Section #}
  {% set sections = craft.sections.getAllSections() %}
  
  {# Loop through all single sections #}
  {% for singleSection in sections if singleSection.type == 'single' %}
  
      {# Get the first (and only) entry of that section #}
      {% set singleEntry = craft.entries.sectionId(singleSection.id).first %}
  
      {# Output #}
      {{ singleSection }}
      {{ singleSection.isHomepage() ? '(Home)' : '(not Home)'}}
      {{ singleEntry.dateUpdated.atom }}
  
  {% endfor %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-26T06:05:17.613Z
Answers.Text: `{{ singleEntry.dateUpdated.atom }}` is returning an error:
  
  `Impossible to access an attribute ("dateUpdated") on a NULL variable ("")`
Answers.UserDisplayName: jnowland
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-26T06:23:02.720Z
Answers.Text: @jnowland sorry, just fixed a bug with my code.
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-05-18T12:38:33.573Z
Answers.Text: How would the code be amended to order the singles listed?
Answers.UserDisplayName: Adam Hopkinson
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-05-28T13:01:34.880Z
Answers.Text: @AdamHopkinson you could try with Super Sort plugin
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-25T07:14:03.073Z
Answers.LastActivityDate: 2014-08-26T06:23:11.773Z
Answers.LastEditDate: 2014-08-26T06:23:11.773Z
Answers.UserDisplayName: carlcs
Body: <p>I'm trying to generate a sitemap and wish to output all the entries that have a <a href="http://buildwithcraft.com/docs/templating/sectionmodel#type" rel="nofollow">section type</a> of 'single' but can't get the the correct syntax.</p>
  
  <p>All of the entries need to return 'single' for <code>{entry.section.type}</code>.</p>
  
  <pre><code>{# This query doesn't work but hopefully helps demo the above question #}
  
  {% for entry in craft.entries.section({'type':'single'}).order('id asc') %}
      &lt;url&gt;
          &lt;loc&gt;{{ entry.url }}&lt;/loc&gt;
          &lt;lastmod&gt;{{ entry.dateUpdated.atom }}&lt;/lastmod&gt;
          &lt;changefreq&gt;weekly&lt;/changefreq&gt;
          {% if entry.section.isHomepage() %}
              &lt;priority&gt;1&lt;/priority&gt;
          {% else %}
              &lt;priority&gt;0.8&lt;/priority&gt;
          {% endif %}
      &lt;/url&gt;    
  {% endfor %}
  </code></pre>
  
  <p><em>Edit:</em></p>
  
  <p><em>This query does work but it's a slow <strong>bad way</strong> of doing it as it gets <strong>EVERY</strong> entry and filters after the fact:</em></p>
  
  <pre><code>{% for entry in craft.entries.order('id asc') if entry.section.type == "single" %}
      &lt;url&gt;
          &lt;loc&gt;{{ entry.url }}&lt;/loc&gt;    
          &lt;changefreq&gt;weekly&lt;/changefreq&gt;
          {% if entry.section.isHomepage() %}
              &lt;priority&gt;1&lt;/priority&gt;
          {% else %}
              &lt;priority&gt;0.8&lt;/priority&gt;
          {% endif %}
      &lt;/url&gt;
  {% endfor %}
  </code></pre>
  
Tags: <sections><elementtype><singles>
Title: How do I return ALL entries that are singles
ThreadText: # How do I return ALL entries that are singles
  
  (Asked by: username_0 on 2014-08-25)
  
  I'm trying to generate a sitemap and wish to output all the entries that have a [section type](http://buildwithcraft.com/docs/templating/sectionmodel#type) of 'single' but can't get the the correct syntax.
  
  All of the entries need to return 'single' for `{entry.section.type}`.
  
  ```
  {# This query doesn't work but hopefully helps demo the above question #}
  
  {% for entry in craft.entries.section({'type':'single'}).order('id asc') %}
      <url>
          <loc>{{ entry.url }}</loc>
          <lastmod>{{ entry.dateUpdated.atom }}</lastmod>
          <changefreq>weekly</changefreq>
          {% if entry.section.isHomepage() %}
              <priority>1</priority>
          {% else %}
              <priority>0.8</priority>
          {% endif %}
      </url>    
  {% endfor %}
  
  ```
  
  *Edit:*
  
  *This query does work but it's a slow **bad way** of doing it as it gets **EVERY** entry and filters after the fact:*
  
  ```
  {% for entry in craft.entries.order('id asc') if entry.section.type == "single" %}
      <url>
          <loc>{{ entry.url }}</loc>    
          <changefreq>weekly</changefreq>
          {% if entry.section.isHomepage() %}
              <priority>1</priority>
          {% else %}
              <priority>0.8</priority>
          {% endif %}
      </url>
  {% endfor %}
  
  ```
  
  **Tags:** sections, elementtype, singles
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2014-08-25. Score: 13 | Accepted answer
  
  There's no such method available for `craft.entries`, at least it's not documented. But you can use [`craft.sections`](http://buildwithcraft.com/docs/templating/craft.sections) to get an array of section models and filter them with a conditional within a loop:
  
  ```
  {# Get all Section #}
  {% set sections = craft.sections.getAllSections() %}
  
  {# Loop through all single sections #}
  {% for singleSection in sections if singleSection.type == 'single' %}
  
      {# Get the first (and only) entry of that section #}
      {% set singleEntry = craft.entries.sectionId(singleSection.id).first %}
  
      {# Output #}
      {{ singleSection }}
      {{ singleSection.isHomepage() ? '(Home)' : '(not Home)'}}
      {{ singleEntry.dateUpdated.atom }}
  
  {% endfor %}
  
  ```
  
  > **Comments:**
  > **username_0**: `{{ singleEntry.dateUpdated.atom }}` is returning an error:  `Impossible to access an attribute ("dateUpdated") on a NULL variable ("")`  
  > **username_2**: @username_0 sorry, just fixed a bug with my code.  
  > **username_3**: How would the code be amended to order the singles listed?  
  > **username_2**: @username_3 you could try with Super Sort plugin  
  
  ---
  
  ### Answer by username_1 on 2015-07-21. Score: 1
  
  This has nothing specifically to do with the question, but this post was very helpful in figuring out how to get all entries that are **channels**. Just wanted to share in case someone else came across this thread. This will return all entries for every channel.
  
  ```
  {% set sections = craft.sections.getAllSections() %}
  {% for channelSection in sections if channelSection.type == 'channel' %}  
  
      {% set channelEntry = craft.entries.sectionId(channelSection.id) %}
          {% for entry in channelEntry %}
              <div class="block {{ channelSection.handle }}">
                  <div class="block-header">
                      <h4><a href="{{ entry.url }}">{{ entry.title }}</a></h4>
                  </div>
                  <div class="block-summary">
                      {{ entry.summary }}
                      <p>
                          <small>(In {{ channelSection }})</small>
                      </p>
                  </div>
                  <div class="block-footer text-right">
                      <i class="fa fa-ellipsis-h"></i>
                  </div>
              </div>
          {% endfor %}
  
  {% endfor %}
  
  ```
  
  As you can see I am using:
  
  ```
  {{ channelSection.handle }}
  
  ```
  
  To generate something like `myChannelHandle` which (could) is useful for creating hooks for css/js.
  
  Hope this helps!
  
  
  ---
  
  