[SOLVED] display only 1 post from certain category with certain params “true”

Hi all. I have an element to show featured content with certain categories so here is my code

achetypes

featured: "true"
categories:
   - photography

template

{{ range first 1 (where .Data.Pages "Type" "blog") }}  
	{{ if and (in .Params.categories "photography") (isset .Params "featured") }}
              bla bla bla...
        {{ end }}
{{ end }}

The code have no error but the problem is the true or false statement on the archetypes have no affect at all.

Kindly show me whats wrong with my conditional code.

=> use true or false without quotes

featured: false

“false” is non zero length text and as such true …

See as well:

Oh i see :slight_smile: I will try it. thank you @it-gro

by the way I’m using different approach like below

{{ range (where .Data.Pages "Type" "blog") 1 }}
     {{ if and (in .Params.categories "photography") (in .Params.featured "true") }} 
         //  MYCODE...
     {{ end }}
{{ end }}

the code working, but Hugo render more than 1 post.

I try the alternative

{{ range first 1 (where .Data.Pages "Type" "blog") }}
the result is nothing rendered.

any clue?

still the mystery for me :sleepy:

I try another approach

{{ $photography := .Data.Pages.ByParam "categories"  }}
{{ if and (in .Params.featured "true") (eq .Params.categories "photography") }}
	{{ range first 1 $photography }} 

the code have no error but it doesnt render at all (blank)

I’m not sure about this but finaly solved using this code

{{range $chap,$tax := .Site.Taxonomies.categories }}
    {{ range first 1 $tax.Pages.ByDate.Reverse }}
    {{  if and (in .Params.categories "photography") (in .Params.featured "true") }}

thanks to @rdwatters Possible to only display 1 post from each taxonomy from list.html?