3

How can I display more than 5 posts in the loop on the homepage of a theme?

I have the standard loop:

{{#foreach posts}}
  <h2 class="post-title">{{{title}}}</h2>
{{/foreach}}

I have 7 posts in total, but can only display 5 per page, it seems to forcibly paginate at 5 posts.

Is there any way I can get around this?

Nicekiwi
  • 4,567
  • 11
  • 49
  • 88
  • Hi, @Nicekiwi! Could you maybe remove the check mark from my answer because it isn’t the right one anymore and I would like to remove, which is only possible when it isn’t tagged as the accepted answer anymore. – PDXIII Jan 09 '18 at 13:12

3 Answers3

19

Since Ghost v1.0, you can change this now by editing the theme's package.json under config. The default Casper theme is probably a good place to look for reference:

"config": {
  "posts_per_page": 25
}
gung - Reinstate Monica
  • 11,583
  • 7
  • 60
  • 79
  • [To reference the doc](https://themes.ghost.org/docs/packagejson#section--config-posts_per_page-) – PaulCo Jul 13 '18 at 00:48
1

By default, Ghost is showing only 5 posts per page. You can change that in the blog settings under general, where you can upload your blog icon and cover, too.

UPDATE: This answer is deprecated!

But it can’t be removed because it was tagged as the accepted answer !

PDXIII
  • 1,086
  • 2
  • 8
  • 17
1

I just had the same issue for my blog.

There are 2 ways you can go about it.

1) Use limit

{{#foreach posts limit="7"}}
 <h2 class="post-title">{{{title}}}</h2>
{{/foreach}}

2) Edit the posts_per_page variable in packaga.json (This will apply to all posts)

//package.json

"config": { "posts_per_page": 7 }
David Nge
  • 59
  • 6