Answers.Body: <p>It might be quicker to turn it around: first get all the entries you need, then group those by their category:</p>
  
  <pre><code>{% set entries = craft.entries.section('people').find() %}
  
  {% for category, catEntries in entries | group('categoryFieldHandle.first().title') %}
      &lt;h1&gt;{{ category }}&lt;/h1&gt;
      {% for entry in catEntries %}
          &lt;a href="{{ entry.url }}"&gt;{{ entry.title }}&lt;/a&gt;
      {% endfor %}
  {% endfor %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-09-25T15:19:31.793Z
Answers.Text: Ok, just tried that and all it's doing is outputting the section name.
Answers.UserDisplayName: Lighty_46
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-09-25T15:22:44.880Z
Answers.Text: Try putting .find() behind the first rule.
Answers.UserDisplayName: Paul
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-09-25T15:33:46.360Z
Answers.Text: Hmmmm, nope still does the same thing.
Answers.UserDisplayName: Lighty_46
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-09-25T15:36:07.930Z
Answers.Text: Wait, it works now for some reason. I used: {% set entries = craft.entries.find({ section: 'people'}) %} in the end. Thanks for the help!
Answers.UserDisplayName: Lighty_46
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-09-25T15:55:22.957Z
Answers.Text: Strange, I would think that those two things have the same result ..
Answers.UserDisplayName: Paul
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-09-26T08:56:17.037Z
Answers.Text: Maybe there was a white space issue or something? anyway it's working now so thanks!
Answers.UserDisplayName: Lighty_46
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-09-25T15:14:40.447Z
Answers.LastActivityDate: 2014-09-25T17:32:54.220Z
Answers.LastEditDate: 2014-09-25T17:32:54.220Z
Answers.UserDisplayName: Paul
Body: <p>Ok, so basically I want to loop through categories and output the title of each category along with all the associated entries. Like so:</p>
  
  <p><strong>Category 1:</strong> Entry 1 Title, Entry 3 Title</p>
  
  <p><strong>Category 2:</strong> Entry 2 Title, Entry 4 Title</p>
  
  <p>(Where entry 1 and 3 are category 1 - and entry 2 and 4 are category 2)</p>
  
  <p>This was the closest I got:</p>
  
  <pre><code>    {% set categories = craft.categories.group('jobCategories').find() %}
  
          {% for category in categories %}
  
              &lt;h1&gt;{{ category.title }}&lt;/h1&gt;
  
              {% for entry in craft.entries.section('people').relatedTo(category).find() %}
  
                  &lt;a href="{{ entry.url }}"&gt;
                       {{ entry.title }}
                  &lt;/a&gt;
  
              {% endfor %}
  
      {% endfor %}
  </code></pre>
  
  <p>How would I do this?</p>
  
  <p>Thanks!</p>
  
Tags: <categories>
Title: How do I output entries by their category?
ThreadText: # How do I output entries by their category?
  
  (Asked by: username_0 on 2014-09-25)
  
  Ok, so basically I want to loop through categories and output the title of each category along with all the associated entries. Like so:
  
  **Category 1:** Entry 1 Title, Entry 3 Title
  
  **Category 2:** Entry 2 Title, Entry 4 Title
  
  (Where entry 1 and 3 are category 1 - and entry 2 and 4 are category 2)
  
  This was the closest I got:
  
  ```
      {% set categories = craft.categories.group('jobCategories').find() %}
  
          {% for category in categories %}
  
              <h1>{{ category.title }}</h1>
  
              {% for entry in craft.entries.section('people').relatedTo(category).find() %}
  
                  <a href="{{ entry.url }}">
                       {{ entry.title }}
                  </a>
  
              {% endfor %}
  
      {% endfor %}
  
  ```
  
  How would I do this?
  
  Thanks!
  
  **Tags:** categories
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2014-09-25. Score: 8 | Accepted answer
  
  It might be quicker to turn it around: first get all the entries you need, then group those by their category:
  
  ```
  {% set entries = craft.entries.section('people').find() %}
  
  {% for category, catEntries in entries | group('categoryFieldHandle.first().title') %}
      <h1>{{ category }}</h1>
      {% for entry in catEntries %}
          <a href="{{ entry.url }}">{{ entry.title }}</a>
      {% endfor %}
  {% endfor %}
  
  ```
  
  > **Comments:**
  > **username_0**: Ok, just tried that and all it's doing is outputting the section name.  
  > **username_1**: Try putting .find() behind the first rule.  
  > **username_0**: Hmmmm, nope still does the same thing.  
  > **username_0**: Wait, it works now for some reason. I used: {% set entries = craft.entries.find({ section: 'people'}) %} in the end. Thanks for the help!  
  > **username_1**: Strange, I would think that those two things have the same result ..  
  > **username_0**: Maybe there was a white space issue or something? anyway it's working now so thanks!  
  
  ---
  
  