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) %}
<div class="container">
<div class="row">
<div class="col-md-12">
<h1>{{ category }}</h1>
</div>
</div>
{% for row in entries.relatedTo(category)|batch(3) %}
<div class="row">
{% for entry in row %}
<div class="col-md-4">
<p>{{ entry.title }}
</div>
{% endfor %}
</div>
</div>
{% endfor %}
</div>