How to display the day of publication?
I have a template that presents entries by month and in that {{month}} {{year}} metadata works. But for each blog entry I want to include the day the blog was published. So if it was publised on the 20/4/2024 then just 20 would be returned. {{day}} would seem the logical construct but it does not work. I also can't find in the documentation where it says {{month}} & {{year}} are up to be used - if I could find that list, hopefully it might shed more light on all this. Thanks as ever.
You can use something like
{{#formatDate}} DD {{/formatDate}}
for day of the month. The documentation for date formats is in the Template developer guide at the bottom of the reference.
Answered 9 months ago · Edit answerThis is great to learn about. I'd never dived into the details of the {{all_entries}}
vs. {{archives}}
. I've used the info to update my archives page, only providing a break out of year. The code I'm using is below, but I'm struggling with one bit (which may not even be possible).
How would I provide the count of posts within the year? I've attempted various things, but my hunch is that the way the array is structured is making it troublesome.
Answered 9 months ago · Edit answerTo provide the number of posts within the year, you can simply do this:
{{#archives}}
<h2>{{year}} - {{entries.length}} posts</h2>
...
```
Answered 9 months ago ·
Edit answer
Thank you. I did try this before, but implemented exactly as you described and get the same behavior. No post count shows up.
<h2>Posts ({{all_entries.length}})</h2>
{{#archives}}
<h2>{{year}} ({{entries.length}})</h2>
{{#months}}
{{#entries}}
<div class="row">
<div class="column left">
<a href="{{{url}}}">{{title}}
{{#tagged.linkpost}}
⇾
{{/tagged.linkpost}}
</a>
</div>
<div class="column right">
<span class="smalldate">{{date}}</span>
</div>
</div>
{{/entries}}
{{/months}}
{{/archives}}
You can see the result live here.
Answered 9 months ago · Edit answerSorry, that was a case of me expecting a feature to exist which does not actually exist. I have just made this work:
<h2>{{year}} - {{total}} post{{s}}</h2>
This is now documented in the developer reference
Answered 9 months ago · Edit answerThanks, David. Truly appreciate the efforts and the pluralization token is just... <chef's kiss>
Answered 9 months ago · Edit answerMany and great thanks for the answer to the original question and important link to the Developers Guide - excellent!
Answered 9 months ago · Edit answer