Create list with posts from the past 7 days


#1

I’m looking to have a list from all blog posts from the past 7 days, i’ve searched and found the following:

{{#get “posts” filter=“published_at:>‘2015-07-20’” limit=“5”}}

Now, how do i get the date to be the current date - 8 days?


#2

Hi Tom,

Handlebars templates are executed server side and cached, therefore they’re not really useful for the kind of dynamic content you’re trying to achieve.

For dynamic content, it’s more appropriate to use client side JavaScript and talk to the API. That way you can have all the dynamic variables you need. There’s a guide for doing this from an external site here: https://api.ghost.org/docs/ajax-calls-from-an-external-website the approach would be the same, only you won’t need to jump through all the hoops with trusted domains, because your Ghost theme already has access to the SDK and API.


#3

Thanks for your quick response!


#4

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.