{{#foreach posts}} not working on custom page

Not sure why, but when I add the following code on my custom page (art.hbs) it doesn’t load any posts.
When this is added to the index.hbs it loads perfectly fine (all posts no limit)

        <div class="showcase-items">
            {{#foreach posts limit="6"}}
                {{> "showcase-item"}}
            {{/foreach}}
        </div>

        <div class="post-feed">
            <div class="grid-item grid-sizer"></div>
            {{#foreach posts from="7"}}
                {{> "loop"}}
            {{/foreach}}
        </div>

Now when I add the following code, the first 6 posts (showcase-items) work fine.
The others though stop at the 15th post.
So something is different in this way of approach?

I then added the following code to the index.hbs to see if it’s because of the {{#get “posts”}}, and yes because it outputs the same on index.hbs as on art.hbs with limited posts.

{{#get "posts" }}
<div class="showcase-items">
    {{#foreach posts limit="6"}}
        {{> "showcase-item"}}
    {{/foreach}}
</div>

<div class="post-feed">
    <div class="grid-item grid-sizer"></div>
    {{#foreach posts from="7"}}
        {{> "loop"}}
    {{/foreach}}
</div>

{{/get}}

Could someone help me out here?

Your theme will limit the number of posts available at once via a setting in package.json.

If you want more posts per page, you can do two things.

Increase the number in package.json, which now seems like it’s 15.

Or, add a limit attribute to your get helper like this: {{ #get “posts” limit=“50”}}. You can specify whatever number you want or “all”

Let me know if that does it!

I changed the number in the package.json but that didn’t work.
I did however add the limit and that seemed to have fixed it.
Thanks :D

1 Like

Glad you got it working! The package.json change would only show up on index routes like your homepage, which is why you might not have seen on your custom page. Regardless, the {{get}} helper is the way to go :grinning: