Log in Sign up

First item in entries array

I'd like to create a link to the most recent post with a specific tag. I can use {{recent_entries}} or {{all_entries}} and filter by tag but I can't find a way to get (or reference) only the first result.

Elsewhere I have pagination of entries working as I want so I don't want to change local.page_size for the whole blog.

Is this possible please?


3 years ago, 3 replies   Edit question

Answering my own question. To get the most recent item for a specific tag I can use:

{{#all_tags}} {{#entries.0}} {{#tagged.coffee}}

{{/tagged.coffee}}

{{/entries.0}} {{/all_tags}}

This is because all_tags outputs each tag with an array of entries in that tag so I can cycle through the first item (using .0) and then filter by the tag I want.

Answered 3 years ago · Edit answer

This might be horrible - I am new to moustache but it works.

Answered 3 years ago · Edit answer

That is an impressive answer! It works

Answered 3 years ago · Edit answer