Incorrect posts length while using {{#get "posts"}} helper

I have made a change in my theme where I am showing the number of posts in my blog in the blog header section.

{{#get "posts"}}
  <header id="blog-header" {{#if @blog.cover_image}} class="has-cover"{{/if}} data-name="{{posts.length}}">
	<div class="inner">
		<nav id="navigation">
			<span class="blog-logo">
				<a href="{{@blog.url}}"><img src="{{@blog.logo}}" alt="{{t "Blog Logo"}}" /></a>
			</span>
			<span id="menu-button" class="nav-button">
				<!--<a class="menu-button"><i class="ic ic-menu"></i> Menu</a>-->
				<a class="menu-button"><i class="fas fa-bars"></i></a>
			</span>
		</nav>
		<h1 class="blog-name">{{@blog.title}}</h1>
		<span class="blog-description">{{@blog.description}}</span>
	</div>
  </header>
{{/get}}

As shown, above I am getting the posts and storing the length of the list returned by this helper in the data attribute data-name.

I have 16 posts in total. But the posts value does not exceed 15. Please refer Thinking Out Loud to reproduce the same.

Here is the Github reference, https://github.com/sneharamnath/attila

1 Like

Hi @Sneha_Ramnath

15 is the default value.
Add “limit” attribute to get more posts, for example {{#get "posts" limit="all"}}

@fueko What purpose does this default solves anyway? And why 15?

The default comes from the theme configuration. The reason the limit exists is to limit fetching unnecessary posts. Most people that use the get helper don’t need (for example) all 3000 posts so there is no reason to fetch them all.

@vikaspotluri123 Makes sense! It however would be nice if ghost exposes a similar API to fetch “total number of posts”. This is a very common requirement in such applications.