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?