Answers.Body: <p>You are so close! All you need to do is to remove the ’.slug’, because that is what the param is expecting.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-09-02T08:12:51.973Z
Answers.Text: Nice, perfect! This is my first Craft/Twig project so these little things pop up a lot haha.
Answers.UserDisplayName: Maarten van Gent
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-09-02T07:52:55.643Z
Answers.LastActivityDate: 2017-09-02T07:52:55.643Z
Answers.UserDisplayName: carlcs
Body: <p>I’m using a structure for creating new pages and navigation. In this structure there are multiple entry types where one is used for creating category pages. Here a user can add some content and select a category that will be used to load projects that are related to it.</p>
  
  <p>In my template I'm using this code to do this:</p>
  
  <pre><code>{% set category = entry.projectCategory.first().slug %}
  {% set params = {
          section: 'projects',
          relatedTo: category
  } %}
  {% set projectEntries = craft.entries(params) %}
  
      &lt;h1&gt;{{ category }}&lt;/h1&gt;
  
      &lt;div&gt;
  {% for projectEntry in projectEntries %}
          &lt;div&gt;
              &lt;a href="{{ projectEntry.url }}"&gt;
                  &lt;div class="index-image"&gt;
                      {% set image = projectEntry.featuredImage.first() %}{% if image %}&lt;img src="{{ image.getUrl('fullImage') }}" alt="{{ image.title }}"&gt;{% endif %}
                  &lt;/div&gt;
                  &lt;div class="index-title"&gt;
                      &lt;h2&gt;{{ projectEntry.title }}&lt;/h2&gt;
                  &lt;/div&gt;
              &lt;/a&gt;
          &lt;/div&gt;
  {% endfor %}
  &lt;/div&gt;
  </code></pre>
  
  <p>First I'm getting the category slug that was selected for this category page. After that I'm setting up my parameters for getting projects (this is another section) that are related to that category.</p>
  
  <p>Before it worked perfectly fine when I had put in a "static" category (so not using the category variable) but when I tried to push the selected category the whole thing stopped working. Even going back to my original code that worked doesn't load any projects.</p>
  
  <p>If I remove the "relatedTo" argument it loads all projects just fine.</p>
  
  <p>Also the slug is perfectly shown in the H1 tag.</p>
  
  <p>Any ideas?</p>
  
Tags: <categories><relations><structure>
Title: Why isn't relatedTo not working (anymore)?
ThreadText: # Why isn't relatedTo not working (anymore)?
  
  (Asked by: username_0 on 2017-09-02)
  
  I’m using a structure for creating new pages and navigation. In this structure there are multiple entry types where one is used for creating category pages. Here a user can add some content and select a category that will be used to load projects that are related to it.
  
  In my template I'm using this code to do this:
  
  ```
  {% set category = entry.projectCategory.first().slug %}
  {% set params = {
          section: 'projects',
          relatedTo: category
  } %}
  {% set projectEntries = craft.entries(params) %}
  
      <h1>{{ category }}</h1>
  
      <div>
  {% for projectEntry in projectEntries %}
          <div>
              <a href="{{ projectEntry.url }}">
                  <div class="index-image">
                      {% set image = projectEntry.featuredImage.first() %}{% if image %}<img src="{{ image.getUrl('fullImage') }}" alt="{{ image.title }}">{% endif %}
                  </div>
                  <div class="index-title">
                      <h2>{{ projectEntry.title }}</h2>
                  </div>
              </a>
          </div>
  {% endfor %}
  </div>
  
  ```
  
  First I'm getting the category slug that was selected for this category page. After that I'm setting up my parameters for getting projects (this is another section) that are related to that category.
  
  Before it worked perfectly fine when I had put in a "static" category (so not using the category variable) but when I tried to push the selected category the whole thing stopped working. Even going back to my original code that worked doesn't load any projects.
  
  If I remove the "relatedTo" argument it loads all projects just fine.
  
  Also the slug is perfectly shown in the H1 tag.
  
  Any ideas?
  
  **Tags:** categories, relations, structure
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-09-02. Score: 3 | Accepted answer
  
  You are so close! All you need to do is to remove the ’.slug’, because that is what the param is expecting.
  
  > **Comments:**
  > **username_0**: Nice, perfect! This is my first Craft/Twig project so these little things pop up a lot haha.  
  
  ---
  
  