<p>I think the answer you’re looking for is <a href="https://craftcms.stackexchange.com/questions/8734/craft-entries-related-on-a-category-page">here</a>.</p>

<p>TL;DR:</p>

<blockquote>
  <p><code>relatedTo</code> method accepts a <code>CategoryModel</code>, not the <code>title</code>(slug) of a category.</p>
</blockquote>

CC BY-SA 3.0
2018-01-28T20:40:10.497Z
Thanks that seemed to do the trick. Had a feeling was missing something fundamental.
SethG
CC BY-SA 3.0
2018-01-28T19:50:41.143Z
2018-01-28T19:50:41.143Z
Christopher Kennedy-Nuñez
<p>I want to generate a list of  events that are related to a specific festival and that are related to a specific category. This goal sits alongside some others that are inspiring me to attempt this in a single template and to do so via building params that are then passed to Craft entries tag. Using Craft 3.</p>

<p>First the base params - these return a fine result.</p>

<pre><code>{# Set base criteria for event query #}
{% set params = {
    section : 'events',
    orderBy : 'eventStartDateTime asc',
    relatedTo: [
        { element: entry.id }
    ],
    limit: null
} %}
</code></pre>

<p>Next here are the params to try and get the events associated with a specific festival entry and that are related to a specific category.</p>

<pre><code>{# Segment 4 is about categories #}
{% if craft.app.request.getSegment(4) %}
    {# segment 4 is the category slug #}
    {% set cat = craft.app.request.getSegment(4) %}
    {% set relationParam = {
        relatedTo: ['and',
            { targetElement: cat },
            { element: entry.id }
        ]
    }%}  

    {% set params = params|merge(relationParam) %}
{% endif %} 
</code></pre>

<p>What I am seeing in this second scenario is I am not getting results filtered by the category. Feel like I am close but missing something, likely fundamental.</p>

<craft3><params><craft.entries>
Trying to build params to be able find entries related to an entry and that are related to a specific category
# Trying to build params to be able find entries related to an entry and that are related to a specific category

(Asked by: username_0 on 2018-01-28)

I want to generate a list of  events that are related to a specific festival and that are related to a specific category. This goal sits alongside some others that are inspiring me to attempt this in a single template and to do so via building params that are then passed to Craft entries tag. Using Craft 3.
First the base params - these return a fine result.
{# Set base criteria for event query #}
{% set params = {
    section : 'events',
    orderBy : 'eventStartDateTime asc',
    relatedTo: [
        { element: entry.id }
    ],
    limit: null
} %}

Next here are the params to try and get the events associated with a specific festival entry and that are related to a specific category.
{# Segment 4 is about categories #}
{% if craft.app.request.getSegment(4) %}
    {# segment 4 is the category slug #}
    {% set cat = craft.app.request.getSegment(4) %}
    {% set relationParam = {
        relatedTo: ['and',
            { targetElement: cat },
            { element: entry.id }
        ]
    }%}  

    {% set params = params|merge(relationParam) %}
{% endif %} 

What I am seeing in this second scenario is I am not getting results filtered by the category. Feel like I am close but missing something, likely fundamental.

**Tags:** craft3, params, craft.entries


---

## 1 answers

### Answer by username_1 on 2018-01-28. Score: 1 | Accepted answer

I think the answer you’re looking for is [here](https://craftcms.stackexchange.com/questions/8734/craft-entries-related-on-a-category-page).

TL;DR:

> `relatedTo` method accepts a `CategoryModel`, not the `title`(slug) of a category.

> **Comments:**
> **username_0**: Thanks that seemed to do the trick. Had a feeling was missing something fundamental.  

---

