{{#author}} not working properly

I’m using the default

taxonomies:
  tag: /tag/{slug}/
  author: /author/{slug}/

inside my author.hbs i’m using the helper {{#author}} wich to be honest i’m not sure what it does

after closing the helper {{/author}}

I’m doing a each helper to go through the posts (this is why i don’t understand what the author helper does since i’m using the posts after i close it…)

{{#each posts }}

My problem is,
I have no idea why posts only has 11 posts in it, when the author has over 60…
also, i’m not sure how to filter by the language tag (since authors will often post in multiple languages, and i want to be able to only show the language that the user wants)

Hey there!

When visiting authors.hbs, there are several pieces of relevant data that are available.

There’s the author data, which includes the author’s name, profile image, bio, etc. You access the author data via {{#author}}. This opens up the author context so that data like name, website, bio, and so on is accessible.

In addition to the author’s data, we also have access to their posts. When looping through the posts in Ghost, use the {{#foreach}} helper (not each). Ghost Handlebars Theme Helpers: foreach

The last (relevant) bit of data available is pagination. Not all posts by the author are served by default to optimize performance. Instead, a limit is defined in the theme’s package.json file. in your case, it sounds like that limit is 11.

Ghost provides the pagination helper as an easy way for the user to go to the next page of an author’s posts.

First of all, super helpful stuff and detailed answer thank you! will change the each to the foreach helper

I do see the 11 on package.json! is there a way could bypass this 11 without setting the limit to 1000? or how could i implement the pagination so that the user can scroll down and fetch the next 11? that would actually be mega awesome for my use case

also, could you tell me how is this “posts” variable being populated to begin with? is it automagicly?

I just joined a company and they’re using ghost and it’s honestly the first time i touch this kind of technologies

Nice. Welcome :wave:

The post limit (11) affects all paginated routes: the home page, author pages, and tag pages. I mention this because making a change in package.json will also make a change on all these pages, too.

Loading additional posts on scroll is possible and called “infinite scroll.” The technique for achieving this is more advanced, though. It requires using the get helper in conjunction with some custom JavaScript.

We have an example of this in our Starter theme:


With the posts variable, Ghost populates that for you behind the scenes based on your theme and routing.

We have a couple tutorials here that may be helpful in getting you up and running: Tutorials

1 Like

Exactly why i didn’t want to change the variable as it might be used somewhere else in the code and would destroy the website haha

I’ll take a look at the example you gave me and the tutorials!

Thank you for beeing so helpful Ryan. :star: :star: :star: :star: :star:

1 Like

Hey Ryan

i’ve tried to follow the example but I can’t seem to find a way to run the function when i scroll down.

i’ve found a way to run it when i enter the page i want to do so (author)

$(function () {
    $.fn.activateScriptIfMatchingURL(
      [
        "/author/",
      ],
      () => {
        infiniteScroll();
        }
    );
  });

But that makes it run as soon as I enter the page… and then it doesn’t run again when I scroll down :/
any insight?

ps. even though it runs when i enter the page it doesn’t actually append another “page” of posts to the list

any news on this issue @RyanF ?

The infinite scroll function that I linked uses the IntersectionObserver API to handle rendering new content via scroll position. It relies on certain class names to work correctly.

Other than that, there’s not enough information in what you provided to determine what’s happening (or not).