Log in Sign up

Showing the most recent entry with a tag?

I'm trying to display the first post in a custom page "writings.html" but if I use the {{#first}} it doesn't show anything.

Could you help me?

{{#allEntries}}
{{#tagged.Writings}}
{{#first}}
<header class=" centered-content">
<a href="{{url}}"><h1>{{title}}</h1></a>
<span class="date">
{{#formatDate}}
Do MMM YYYY 
{{/formatDate}}
</span>  
</header>
<section class="writings centered-content">
{{{body}}}
</section>
{{/first}}
{{/tagged.Writings}}
{{/allEntries}}

9 months ago, 1 replies   developers   Edit question

This sort of dynamic filtering doesn't quite work, first is only set for the first item in the allEntries list and not for the first item with the tag writing.

For now, you can use CSS to hide all the other entries:

<style type="text/css">
.show-only-first .writing {display:none}
.show-only-first .writing:first-child {display:block}
</style>
<div class="show-only-first">
{{#allEntries}}
{{#tagged.Writings}}
<section class="writing">
...
</section>
{{/tagged.Writings}}
{{/allEntries}}

I eventually plan to add this sort of dynamic filtering / querying, though

Answered 9 months ago ยท Edit answer