<p>The code above is correct and working properly. There was a conflict with a masonry js file making the Craft ordering not work. Big thanks to @Anubarak for testing the code on their side.</p>

CC BY-SA 3.0
2017-10-18T17:35:08.713Z
2017-10-18T17:35:08.713Z
Jon Livingston
<p>I'm stumped trying to order paginated entries for a channel. The end goal is to have listings with the most recent postDate at the top. The code below has the most recent item third instead of first. The first item should be third.</p>

<p>The same happens as you paginate to the next page. The third item listed should be the first item listed.</p>

<pre><code>{% paginate craft.entries.section('podcastEpisodes').order('postDate desc').limit('3') as pageInfo, pageEntries %}
{% for entry in pageEntries  %}

{% set category = entry.topic.first() %}
    &lt;div class="masonry__item" data-masonry-filter="{% if category %}{{ category.title }}{% endif %}"&gt;

    &lt;article&gt;
        &lt;p class="date"&gt;{{ entry.postDate|date('M j, Y') }}&lt;/p&gt;

        {% set myEntry = entry.podcaster.first() %}
        {% if myEntry %}
        &lt;p class="podcaster"&gt;{{ myEntry.title }}&lt;/p&gt;
        {% endif %}

        &lt;h4&gt;{{ entry.title }}&lt;/h4&gt;
    &lt;/article&gt;

    &lt;/div&gt;
{% endfor %}
</code></pre>

<p>Any idea why this is happening?</p>

CC BY-SA 3.0
2017-10-18T04:51:36.770Z
What happens when you try to use dateCreated instead of postDate?
Robin Schambach
CC BY-SA 3.0
2017-10-18T12:23:17.800Z
Same thing happens. The most recent entry is third on list, with the third entry in the first spot (when limiting it to 3 entries per page).
Jon Livingston
CC BY-SA 3.0
2017-10-18T12:48:29.287Z
Really strange, when I copy your code, remove the category and myEntry part and change `podcastEpisodes` to a sectionhandle of my system it works. Do you see the correct order in your backend? Maybe you could search in your database if the entries have the correct postDate there.
Robin Schambach
CC BY-SA 3.0
2017-10-18T17:32:44.967Z
@Anubarak - Thank you! Your comment made me realize there was something larger going on. I found a masonry js file that was sorting entries differently than Craft. The code above is correct and working properly now that the js file was changed.
Jon Livingston
<pagination><ordering><postdate>
Order a paginated entry by postDate
# Order a paginated entry by postDate

(Asked by: username_0 on 2017-10-18)

I'm stumped trying to order paginated entries for a channel. The end goal is to have listings with the most recent postDate at the top. The code below has the most recent item third instead of first. The first item should be third.
The same happens as you paginate to the next page. The third item listed should be the first item listed.
{% paginate craft.entries.section('podcastEpisodes').order('postDate desc').limit('3') as pageInfo, pageEntries %}
{% for entry in pageEntries  %}

{% set category = entry.topic.first() %}
    

    
        {{ entry.postDate|date('M j, Y') }}

        {% set myEntry = entry.podcaster.first() %}
        {% if myEntry %}
        {{ myEntry.title }}
        {% endif %}

        {{ entry.title }}
    

    
{% endfor %}

Any idea why this is happening?

**Tags:** pagination, ordering, postdate
> **Comments:**
> **username_1**: What happens when you try to use dateCreated instead of postDate?  
> **username_0**: Same thing happens. The most recent entry is third on list, with the third entry in the first spot (when limiting it to 3 entries per page).  
> **username_1**: Really strange, when I copy your code, remove the category and myEntry part and change `podcastEpisodes` to a sectionhandle of my system it works. Do you see the correct order in your backend? Maybe you could search in your database if the entries have the correct postDate there.  
> **username_0**: @Anubarak - Thank you! Your comment made me realize there was something larger going on. I found a masonry js file that was sorting entries differently than Craft. The code above is correct and working properly now that the js file was changed.  

---

## 1 answers

### Answer by username_0 on 2017-10-18. Score: 2

The code above is correct and working properly. There was a conflict with a masonry js file making the Craft ordering not work. Big thanks to @Anubarak for testing the code on their side.


---

