I want to create a featured story slider on my website and gather the latest entries from multiple channels to populate it.
Here is what is working:
# fetch the entries
{% set featuredBlog = craft.entries.section('blogs').limit(1).find() %}
{% set featuredArticle = craft.entries.section('articles').limit(1).find() %}
{% set featuredSpecialReport = craft.entries.section('specialReports').limit(1).find() %}
{% set featuredInfographic = craft.entries.section('infographics').limit(1).find() %}
# create a collection out of the above entries
{% set allEntries =
featuredBlog|merge(featuredArticle)|merge(featuredSpecialReport)|merge(featuredInfographic) %}
# loop over the collection and output them
{% for featuredEntry in allEntries %}
{{ featuredEntry.title }}<br>
{% endfor %}
Now I want to sort the collection of entries by postDate
so that the latest entry in the collection shows up first, no matter what section it is from. How do I do this?
I tried:
{% for featuredEntry in allEntries|group('postDate.day') %}
{{ featuredEntry.title }}<br>
{% endfor %}
But this doesn't work and crashes the template saying Key "title" for array with keys "0, 1, 2" does not exist
So how do I sort a collection of entries from multiple sections and show them by latest date descending?