Featured Posts & Latest Posts block: not displaying duplicates

I am running Ghost(Pro) which is on v4.8.4.

What I am trying to accomplish on the front page is have two sections:

  1. Featured Posts: pulls the most recent 3 featured posts
  2. Latest Posts: pulls the most recent 8 posts, followed by a “show more posts” button which dynamically pulls the next set of 8 posts.

This is easy to do in and of itself, so no issues with the above basic logic.

Essentially using the following to accomplish the basics:

            <h2>Featured Posts</h2>
            {{#get "posts" limit="3" include="tags,authors" filter="featured:true"}}
                {{#foreach posts}}
                {{> post-item}}
                {{/foreach}}
            {{/get}}

            <h2>Latest Posts</h2>
            {{#foreach posts}}
                {{> post-item}}
            {{/foreach}}

What I would like to do, if it is possible, is not have any of the posts showing in Featured Posts also be displayed in the Latest Posts block. The above method results in duplicate posts, which I guess is fine in the grand scheme, but I would prefer to hide the posts if this is possible.

Surely I am missing something super simple and easy? I checked the docs but cannot really find anything useful to help solve this problem.

Hi @scottie,

I see two options for this:

  1. Exclude the featured posts from the default collection. (filter in routes.yaml)
  2. Within the latest posts {{#foreach}} you can check whether the post is featured and you can opt to skip it:
{{#unless featured}}
  {{> post-item}}
{{/unless}}

Hi @bironthemes,

Thank you for the suggestion. I will give this a shot and see if it works out and matches my expectations. :bowing_man:

Just thinking out loud here. One concern I have is the Featured Posts section is limited to the most recent three features. So featured posts #4 and older need to be present in the Latest Posts block otherwise they will never been “seen”.

I suspect there is no easy way to achieve this, yeah?

You are right, if you just want to exclude those 3 posts then there is not straightforward way to do it. I guess you would have to use come kind of nested get, but that has its limitations.