I’m having some difficulty getting custom pagination working, and I’m not sure what I’m doing wrong. On my home/index page, I have a pagination of content, and up until now I’ve been using the default .Paginator. However, I want to use a custom one that filters out posts that have draft: true set in their parameters.
Currently, I’m doing $pag := .Paginate (where .Site.RegularPages "Params.hidden" "ne" "true" and then loop over all the pages range $pag.Pages. However, this includes a post with hidden: true in the front-matter. What am I doing wrong?
Sorry for the late response, but I’ve been messing with this some more and can’t get it to work at all, I’m doing .Paginate (where .Site.RegularPages "Params.hidden" "ne" true). It just gives the same result as the default pagination.
I wanted to see if I could get any custom pagination working, so I tried {{ range (.Paginate .Site.Taxonomies.tags).Pages }}{{ .Title }}{{ end }} to see if I could get it to print out the names of some of my tags, but that did the same thing, just printing out the name of a few posts.
Any ideas what I’m doing wrong? I’m super confused. Thanks!
Still no luck. The project repo is here; my theme is a submodule, source here. The pagination I’m having troubles with is here. Any help would be greatly appreciated! Thanks in advance. I probably missed out something small.
The .Paginator is static and cannot change once created.
If you call .Paginator or .Paginate multiple times on the same page, you should ensure all the calls are identical. Once either.Paginator or .Paginate is called while generating a page, its result is cached, and any subsequent similar call will reuse the cached result. This means that any such calls which do not match the first one will not behave as written.