<p>Read the article about <a href="http://buildwithcraft.com/docs/templating/elementcriteriamodel" rel="noreferrer">ElementCriteriaModel</a> in the official Craft docs on how to query elements in general and the <a href="http://buildwithcraft.com/docs/templating/craft.entries" rel="noreferrer">craft.entries</a> article about the parameter available to modify the object returned.</p>

<p>Example code for your events list:</p>

<pre class="lang-twig prettyprint-override"><code>{# Get events from `events` section in desired sort order #}
{% set allEvents = craft.entries.section('events').order('eventsDate desc') %}

{# Loop through `allEvents` and print the list #}
{% for event in allEvents %}
    &lt;li&gt;{{ event.eventsHeadline }} - {{ event.eventsDate|date('F j, Y') }}&lt;/li&gt;
{% endfor %}
</code></pre>

CC BY-SA 3.0
2014-07-15T10:41:16.970Z
If I was wrong and "eventsFeed" is an entries field, query your events with the [`relatedTo()`](http://buildwithcraft.com/docs/relations#the-relatedTo-param) parameter.
carlcs
CC BY-SA 3.0
2014-07-15T11:03:48.383Z
Yes, eventsFeed is an entries field, . Could you update your example code for the events list? Meanwhile, I'll read the articles you suggested.
osh
CC BY-SA 3.0
2014-07-15T11:06:15.323Z
I can't because you first have to provide more info.
carlcs
CC BY-SA 3.0
2014-07-15T11:59:02.697Z
Sorry about that. I just updated my question.
osh
CC BY-SA 3.0
2014-07-15T09:57:19.080Z
2014-07-15T14:18:29.640Z
2014-07-15T14:18:29.640Z
carlcs
<p>I have a channel section with a handle named 'events'. </p>

<p>In my field layout for this section I have a field named eventsDate, which is a Date/Time field.</p>

<p>I also have a plain text field called 'eventsHeadline'. </p>

<p>What would be a good way to output the 'eventsHeadline' entries ordered by 'eventsDate'?</p>

CC BY-SA 3.0
2014-07-15T09:35:05.090Z
Is "eventsFeed" an entries field or did you mean it's a section? If it really is an entries field, what's the section handle of your sections and where do you use the datetime field "eventsDate"?
carlcs
CC BY-SA 3.0
2014-07-15T14:19:46.260Z
Ok. "eventsFeed" is missing altogether now, updated my answer :)
carlcs
<entries><datetime><elementcriteriamodel><ordering>
Order entries by date field
# Order entries by date field

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

I have a channel section with a handle named 'events'.

In my field layout for this section I have a field named eventsDate, which is a Date/Time field.

I also have a plain text field called 'eventsHeadline'.

What would be a good way to output the 'eventsHeadline' entries ordered by 'eventsDate'?

**Tags:** entries, datetime, elementcriteriamodel, ordering

> **Comments:**
> **username_1**: Is "eventsFeed" an entries field or did you mean it's a section? If it really is an entries field, what's the section handle of your sections and where do you use the datetime field "eventsDate"?  
> **username_1**: Ok. "eventsFeed" is missing altogether now, updated my answer :)  

---

## 1 answers

### Answer by username_1 on 2014-07-15. Score: 13 | Accepted answer

Read the article about ElementCriteriaModel in the official Craft docs on how to query elements in general and the craft.entries article about the parameter available to modify the object returned.
Example code for your events list:
{# Get events from `events` section in desired sort order #}
{% set allEvents = craft.entries.section('events').order('eventsDate desc') %}

{# Loop through `allEvents` and print the list #}
{% for event in allEvents %}
    {{ event.eventsHeadline }} - {{ event.eventsDate|date('F j, Y') }}
{% endfor %}

> **Comments:**
> **username_1**: If I was wrong and "eventsFeed" is an entries field, query your events with the [`relatedTo()`](http://buildwithcraft.com/docs/relations#the-relatedTo-param) parameter.  
> **username_0**: Yes, eventsFeed is an entries field, . Could you update your example code for the events list? Meanwhile, I'll read the articles you suggested.  
> **username_1**: I can't because you first have to provide more info.  
> **username_0**: Sorry about that. I just updated my question.  

---

