Cursom where for $paginator

Hello. I have a custom article with parameter

## Meta
description		= "Desc"
title			= "Title"

## Date
date			= "2020-07-28T00:00:00+03:00"

## Short data
hide_public		= true
+++

And I have the code in Section

			{{ $paginator := .Paginate (where (where .Pages "Type" "blog").ByDate.Reverse .Params.hide_public "==" true) }}

			{{ $p := $paginator.PageNumber }}
			{{ $n := $paginator.NumberOfElements }}
					{{ range $k, $v := $paginator.Pages }}
					{{ if lt $k 4 }}
					{{ .Render "blog_section.li" }}
					{{ end }}
					{{ end }}

Why the condition

Params.hide_public “==” true

doesn’t work?

I tried that
{{ $paginator := .Paginate (where (where .Pages "Type" "blog") ".Params.hide_public" "ne" true) }}
no result :frowning:

{{- $paginator := .Paginate (where (where .Site.RegularPages.ByDate.Reverse "Type" "blog") "Params.hide_public" true) }}

It doesn’t work too :frowning:

HUGO v0.74.3

Yes, it does work.

git clone --single-branch -b hugo-forum-topic-27207 https://github.com/jmooring/hugo-testing hugo-forum-topic-27207
cd hugo-forum-topic-27207
hugo server

This example site has 20 blog posts. The odd-numbered posts have hide_public = true, while the even-numbered posts have hide_public = false.

1 Like

Thank you. My mistake was that I use the same code in particle template in header.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.