1

I need to order blog posts by year and month so the output would be someting like...

June 2013
Blog Title 1
Blog Title 2

May 2013
Blog Title 3
Blog Title 4

December 2012
Blog Title 5

How can I achieve this. Any help most appreciated. Thanks

3

You should use a date_heading.

{exp:channel:entries [...]}
    {date_heading display="monthly"}{entry_date format="%F %Y"}{/date_heading}
    [...]
{/exp:channel:entries}

The value of the parameter "display" will set when the code on {date_heading} variable pair will be repeated.

Please, forgive the simple code sample, but you don't gave more details.

3
  • I will try that now. Thanks. I don't have enough rep to to Vote Up. – cfb Jun 10 '13 at 19:17
  • If you need more info, please improve your answer with a sample code. – Sobral Jun 10 '13 at 19:36
  • As Robson said.. date_heading AND date_footer is the solution.. Then you can group by days, week, months, year.. – Benoit L Jul 7 '17 at 16:10
2

Using Low Yearly Archives, you can do something like that:

{exp:low_yearly_archives channel="blog" status="not closed" sort="desc" monthsort="desc"}
    {months}
        {if num_entries != 0}
        <h2>{month} {year}</h2>
        <ul>
        {embed="news/archives_month" y="{year}" m="{month_num_short}"}
        </ul>
      {/if}
    {/months}
{/exp:low_yearly_archives}

And in your archives_month embed, something along those lines (we embed to get the parsing order for {month_num_short} right):

{exp:channel:entries
    channel="blog"
    disable="custom_fields|categories|category_fields|member_data|pagination|trackbacks"
    dynamic="off"
    year="{embed:y}"
    month="{embed:m}"
    sort="asc"
}
<li><a href="{url_title_path=blog}">{title}</a></li>
{/exp:channel:entries}
0

You might use "Low Yearly Archives" plugin. Find the doc from here http://gotolow.com/addons/low-yearly-archives

3
  • Thanks. I tried Low Yearly Archives and was able to output by year and month but not pull out the actual blog posts. Not sure how to do that. – cfb Jun 10 '13 at 19:19
  • Well, use Low Yearly Archive plugin to populate the years and month in descending order. Within it just put the channel entry tag with parameter year and month like year="{year}" and month="{month}". – Bhashkar Yadav Jun 11 '13 at 4:35
  • month="{month}" results in all entries for the channel being displayed. What am I missing? If i hardcode e.g. month="2" it works, but how can I make it dynamic? – Stian Karlsen Feb 14 '14 at 20:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.