{{has}} helper doesn't return all the posts with a tag

  • What’s your URL? https://input.sh
  • What version of Ghost are you using? 3.13.3

In partials/musicLoop.hbs, I have this structure:

{{#foreach posts visibility="all"}}
{{#has tag="Music"}}
    <div>HTML code here</div>
{{/has}}
{{/foreach}}

Within my tags page, I see the following:

All four posts are published.

So I expect to see all four of them on my website when calling this partial. However, I’m getting this as a result:

That’s just the first two results. There should also be top 16 of 2016 and top 15 of 2015 there.

What am I doing wrong?

home.hbs that loads the partial, in case it’s of any help:

{{!< default}}
{{> "featuredPosts"}}
{{> "latestPost"}}

<div id="main">
    <div class="container">
        <h2 class="homepage-section-title">Posts</h2>
        <div class="row">
            {{> "postLoop"}}
        </div>
    </div>
    <div class="container">
        <h2 class="homepage-section-title">Pages</h2>
        <div class="row">
            {{> "pageLoop" }}
        </div>
    </div>
    <div class="container">
        <h2 class="homepage-section-title">Music</h2>
        <div class="row">
            {{> "musicLoop" }}
        </div>
    </div>
</div>

{{pagination}}

{{#foreach posts}} will only loop over the posts displayed on the current page.

If you’re trying to work with content from across the whole site then you’re probably looking for the {{#get}} helper.

Yup, replacing the partial with:

{{#get "posts" filter="tags:music" }}
{{#foreach posts }}
    <div>HTML code here</div>
{{/foreach}}
{{/get}}

...did the trick. Thanks for the tip!