Answers.Body: <p>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:</p>
  
  <pre><code>{% 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 %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-20T08:13:49.023Z
Answers.Text: This works perfectly. Added a category template. Thanks @carlcs
Answers.UserDisplayName: jjem
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-19T17:09:58.047Z
Answers.LastActivityDate: 2014-11-19T17:09:58.047Z
Answers.UserDisplayName: carlcs
Body: <p>This is the code used to display entries related to categories.</p>
  
  <p>The issue: if an entry belongs to 2 categories, it displays all the categories to which it belongs on the page. </p>
  
  <p>I need Craft to display only the category and entries the (lastSeg) of the slug (selected from a nav).</p>
  
  <p>Can't find where to start?</p>
  
  <pre><code>{% 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;
  </code></pre>
  
Tags: <categories>
Title: List entries related to several categories
ThreadText: # List entries related to several categories
  
  (Asked by: username_0 on 2014-11-19)
  
  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>
  
  ```
  
  **Tags:** categories
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2014-11-19. Score: 2 | Accepted answer
  
  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() %}
  
  <h1>{{ category.title }}</h1>
  
  {% set entries = craft.entries.section('contenuCompositions').relatedTo(category) %}
  
  {% for entry in entries %}
      {{ entry.title }}
  {% endfor %}
  
  ```
  
  > **Comments:**
  > **username_0**: This works perfectly. Added a category template. Thanks @username_1  
  
  ---
  
  