Hello,
How to create templates for content collections or channels with pagination?
I have followed this article: https://ghost.org/tutorials/creating-content-collections/
Suppose I have a collection called tweets with tag hash-tweet. I have assigned it in routes.yaml file like this:
collections:
/tweets/:
permalink: /tweets/{slug}/
template: tweets
filter: tag:hash-tweet
Then I created a template file called tweets.hbs with this:
{{#get “posts” include=“tags,authors” visibility=“all” filter=“tags:hash-tweet” limit=“all”}}
{{#foreach posts order=“published_at desc” limit=@config.posts_per_page}}
{{> “loop”}}
{{/foreach}}
{{/get}}
{{pagination}}
I have tried it both for collections and channels. Everything is working but pagination is not working well. On the second or third page, it shows the same posts as the first page. If I remove the limit in “foreach” it shows all posts on the first page but I want to split them with pagination. The same thing happens in channels. Please help me out with this.
I am using Ghost version: 3.38.2 and a custom theme.
Thank you!
Anisul