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/

I’ve created a shortcode tripsummary.html with:

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

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

- Madeira
- Madeira 2019

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


This page in the docs is probably helpful:

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 }}

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>
     {{ $pages := where .Site.Pages "Params.trip" $trip }}
     {{ range $pages.ByDate }}
     <li><a href="{{ .URL }}" target="_blank">{{ .Title }} </a> </li>
     {{ end }}

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