I have a custom post type “Kalender_item” with a custom Date Field (YYMMDD). I want to list all the posts on a page sorted by Year and Month.
For example:
- November 2012 (all events that occure in November 2012)
- December 2012 (all events that occure in December 2012)
And so on…
I have succeeded in ordering them like so
$kalenderItems=query_posts('post_type=kalender_item&post_status=publish&meta_key=kalender_item_datum&orderby=meta_value');
This gives me all my posts in the correct order. Now I want to group them by Month Year and display the Month Year as a title for each group.
How to group my results by year and month?
This should get you started: