Skip to content

Is it possible to group blog pages by relative date? #959

Answered by pftnhr
pftnhr asked this question in Ask a question
Discussion options

You must be logged in to vote

Here's the solution:

Create a variable from the group

<?php foreach ($collectionMonth->group("published", false, "Y-m-d") as $day=>$collectionDay):
    $relDay = $collectionDay[0]->getDateRelative("published");
?>

Then you can output it at your desired position within the group:

<time class="dt-published published postdate" datetime="<?php echo date(DATE_ISO8601, strtotime($day)) ?>">
    <?php echo $relDay ?>
</time>

Replies: 0 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by pftnhr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant