Shortcode with filter by taxonomy

Hi there!
I’m trying to list the members of a taxonomy in a shortcode without any success; I’ve taken a look at previous posts (like this ) but I don’t really understand the solution. (also, I didn’t revive the old conversation because it may notify many people).

I’d like to add something like this:

{{< tripsummary tripName="madeira-2019" >}}  

in my content/post/xxx.md

I’ve created a shortcode tripsummary.html with:

 {{ $tripName := .Get "tripName" }}
 <section class="tripsummary">
   {{ range where $tripName "in" ".site.Params.trips" }}
     {{ .Render "title" }}
   {{ end }}
 </section>

the problem is the where clausule

This “trips” taxonomy goes in the frontmatter of every post I want to relate to a trip, like:

---
author: yamila
date: 2019-02-19T08:00:00.000Z
slug: madeira-2019-funchal-y-curral-das-freiras
title: Madeira 2019 - Funchal y Curral das Freiras
thumbnailImage: https://farm8.staticflickr.com/7849/46264969955_ce3ed8795b_z.jpg
coverImage: https://farm8.staticflickr.com/7849/46264969955_ce3ed8795b_b.jpg

tags:
- Madeira
trips:
- Madeira 2019
---

any hint would be appreciated! Thanks for your time :slight_smile:

Hi,

This page in the docs is probably helpful: https://gohugo.io/templates/taxonomy-templates/#list-all-content-in-a-given-taxonomy

Modifying that example a little:

{{ $tripName := .Get "tripName" }}
<section class="tripsummary">
  {{ range $key, $taxonomy := site.Taxonomies.trips }}
    {{ if eq $key $tripName }}
      {{ range $taxonomy.Pages }}
        {{ .Title }}<br>
      {{ end }}
    {{ end }}
  {{ end }}
</section>

should get you most of the way to what you want to accomplish.

Hi! Thanks for your answer and for your help; I missed that page in the documentation!! In the end, I changed the taxonomy (from a list to a only-one value, which is more semantically accurate) so I could do this with less lines:

 {{ $trip := .Get "trip" }}
 <section class="tripindex">
   <h3>Índice de posts de  {{ $trip }}</h3>
   <ol>
     {{ $pages := where .Site.Pages "Params.trip" $trip }}
     {{ range $pages.ByDate }}
     <li><a href="{{ .URL }}" target="_blank">{{ .Title }} </a> </li>
     {{ end }}
   </ol>
 </section>

I hope this snippet is useful for other people. Again, thank you very much for your help!