<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>

CC BY-SA 3.0
2015-07-21T22:27:45.927Z
2015-07-21T22:27:45.927Z
Damon
<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>

CC BY-SA 3.0
2014-08-26T06:05:17.613Z
`{{ singleEntry.dateUpdated.atom }}` is returning an error:

`Impossible to access an attribute ("dateUpdated") on a NULL variable ("")`
jnowland
CC BY-SA 3.0
2014-08-26T06:23:02.720Z
@jnowland sorry, just fixed a bug with my code.
carlcs
CC BY-SA 3.0
2017-05-18T12:38:33.573Z
How would the code be amended to order the singles listed?
Adam Hopkinson
CC BY-SA 3.0
2017-05-28T13:01:34.880Z
@AdamHopkinson you could try with Super Sort plugin
carlcs
CC BY-SA 3.0
2014-08-25T07:14:03.073Z
2014-08-26T06:23:11.773Z
2014-08-26T06:23:11.773Z
carlcs
<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>

<sections><elementtype><singles>
How do I return ALL entries that are singles
# 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 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') %}
    
        {{ entry.url }}
        {{ entry.dateUpdated.atom }}
        weekly
        {% if entry.section.isHomepage() %}
            1
        {% else %}
            0.8
        {% endif %}
        
{% 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" %}
    
        {{ entry.url }}    
        weekly
        {% if entry.section.isHomepage() %}
            1
        {% else %}
            0.8
        {% endif %}
    
{% 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 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**: @AdamHopkinson 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 %}
            
                
                    {{ entry.title }}
                
                
                    {{ entry.summary }}
                    
                        (In {{ channelSection }})
                    
                
                
                    
                
            
        {% 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!


---

