List entries related to several categories This is the code used to display entries related to categories.

The issue: if an entry belongs to 2 categories, it displays all the categories to which it belongs on the page. 

I need Craft to display only the category and entries the (lastSeg) of the slug (selected from a nav).

Can't find where to start?

{% set entries = craft.entries.section('contenuCompositions').relatedTo(category).order('dateYear','comp_opus','title').limit(0) %}
{% for category in craft.categories.group('compositions').relatedTo(entries).level(2).slug(lastSeg) %}
&lt;div class="container"&gt;
&lt;div class="row"&gt;
    &lt;div class="col-md-12"&gt;
        &lt;h1&gt;{{ category }}&lt;/h1&gt;
    &lt;/div&gt;
&lt;/div&gt;
{% for row in entries.relatedTo(category)|batch(3) %}
&lt;div class="row"&gt;
    {% for entry in row %}
      &lt;div class="col-md-4"&gt;
        &lt;p&gt;{{ entry.title }}
      &lt;/div&gt;
    {% endfor %}
&lt;/div&gt;
&lt;/div&gt;
{% endfor %}
&lt;/div&gt;
Not sure if this is still what you are after (I removed a lot of parameters), but basically this gets the one (!) category with the unique (!) slug you request from the URL and then lists the entries related to it:

{% set categorySlug = craft.request.getLastSegment() %}
{% set category = craft.categories.group('compositions').slug(categorySlug).first() %}

&lt;h1&gt;{{ category.title }}&lt;/h1&gt;

{% set entries = craft.entries.section('contenuCompositions').relatedTo(category) %}

{% for entry in entries %}
    {{ entry.title }}
{% endfor %}