<p>Have part of the solution which is to use:</p>

<pre><code>{% set categories = entry.categoriesFieldHandle %}
{% if categories | length %}

&lt;h3&gt;Some great categories&lt;/h3&gt;
{% nav category in categories %}
    {%for entry%}
    {%endfor%}

{% endnav %}
{% endif %}
</code></pre>

<p>Just now need to find out how to add the Category Title in and work on separating the entries out.</p>

CC BY-SA 3.0
2017-09-23T23:18:39.140Z
2017-09-24T20:14:22.207Z
2017-09-24T20:14:22.207Z
Matthew Dillon
<p>I am trying to pull channel entries and display them using a loop. These entries would then be organized by the category they are assigned to based on a categoryfield a user selects when creating the entry. Below is the code I am beginning with.</p>

<pre><code>{% set category = entry.myCategoriesField.first() %}
{% if category %}
 {% for car in craft.entries.section('category')%}
  **Might need a set option here for entries??**

  {{car.Title}}
  {{car.carDescription}}

 {%endfor%}
{% endif %}
</code></pre>

<p>Should look like:</p>

<p>Car</p>

<ul>
<li>Prius: {{Description}}</li>
</ul>

<p>Truck</p>

<ul>
<li>Ram {{Description}}</li>
<li>Silverado{{Description}}</li>
</ul>

<p>SUV</p>

<ul>
<li>Suburban {{Description}}</li>
<li>Escape {{Description}}</li>
</ul>

<p>Any thoughts or direction would be helpful.</p>

<p>I have looked into the following code but don't think it would work the way I want to.</p>

<pre><code>{% set category = entry.myCategoriesField.first() %}
{% if category %}
    ...
{% endif %} 
</code></pre>

<categories><craft3>
Pulling categorized entries in a category loop
# Pulling categorized entries in a category loop

(Asked by: username_0 on 2017-09-23)

I am trying to pull channel entries and display them using a loop. These entries would then be organized by the category they are assigned to based on a categoryfield a user selects when creating the entry. Below is the code I am beginning with.
{% set category = entry.myCategoriesField.first() %}
{% if category %}
 {% for car in craft.entries.section('category')%}
  **Might need a set option here for entries??**

  {{car.Title}}
  {{car.carDescription}}

 {%endfor%}
{% endif %}

Should look like:
Car

Prius: {{Description}}

Truck

Ram {{Description}}
Silverado{{Description}}

SUV

Suburban {{Description}}
Escape {{Description}}

Any thoughts or direction would be helpful.
I have looked into the following code but don't think it would work the way I want to.
{% set category = entry.myCategoriesField.first() %}
{% if category %}
    ...
{% endif %}

**Tags:** categories, craft3

---

## 1 answers

### Answer by username_0 on 2017-09-23. Score: 1

Have part of the solution which is to use:
{% set categories = entry.categoriesFieldHandle %}
{% if categories | length %}

Some great categories
{% nav category in categories %}
    {%for entry%}
    {%endfor%}

{% endnav %}
{% endif %}

Just now need to find out how to add the Category Title in and work on separating the entries out.


---

