Obtaining 6 posts with "Draft false"

Hello guys.

I’m trying to obtain 6 posts (with Params .Draft FALSE) to have in home page by the following query:

{{ range where (.Paginator 6).Pages ".Draft" false }}

However this takes the last 6 pages, it checks for each one if the params is draft. This pones a problem.
A given example to clarify, I have:

  • hello world (draft)
  • post-2
  • post-3
  • post-4 (draft)
  • post-5
  • post-6
  • post-7
  • post-8
    […] and so on

The result should be:
(takes the 6 last post with “Draft” false)

  • post-2
  • post-3
  • post-5
  • post-6
  • post-7
  • post-8

HOWEVER I obtain the following result:
(takes the 6 last pages, and then compares… naturally some posts are “forgotten”)

  • post-2
  • post-3
  • post-5
  • post-6
{{ range first 6 (where .Paginator.Pages ".Draft" false) }}
1 Like