In this example, I'm trying to show entries with the category "Beer". This works:
{% set myCategory = craft.categories.slug('beer') %}
{% if entry.relatedDrinks.relatedTo(myCategory)|length %}
<h1>Beers</h1>
{% for beer in entry.relatedDrinks.relatedTo(myCategory) %}
{{beer.title }}
{% endfor %}
{% endif %}
I also want to limit these entries to a certain year (not defined by Entry Date). I've created a Section called "Product Year" with entries such as "2020" and "2021". Within the entry for the beer, I've added an Entries field to select the year defined in the Product Year section. I'm not sure how to use that Product Year relation as a filter.
I'm essentially trying to say {% if entry.relatedDrinks.relatedTo(myCategory)|length "and product year is 2020 "%}