<p>After some further research this <a href="http://craftcookbook.net/recipes/279" rel="nofollow">http://craftcookbook.net/recipes/279</a> was a better fit for my needs.  The code I ended up using based on the link is below.</p>

<pre><code>{% set beer = [] %}
{% set beerBrands = craft.categories.group('brandCategory').level(1).find() %}
    {% for category in beerBrands %}
         {% set beerRelatedCategories = craft.entries.section('beers').relatedTo(category).find() %}
         {% set beer = beer|merge(beerRelatedCategories) %}
    {% endfor %}
</code></pre>

CC BY-SA 3.0
2015-12-02T04:12:44.230Z
2015-12-02T04:12:44.230Z
triplethreat23
<p>I currently have entries from a section output simply using a variable like:</p>

<pre><code>{% set beer = craft.entries.section('beverages') %}
</code></pre>

<p>All of the beer entries have brands assigned to them using the category field.  How can I display the beer entries by brand? I use that beer variable throughout my templates for entry counts, filters, etc. I'd like to try and keep that in tact if possible.</p>

<p>I tried to use this but it seems to do more than what I need: <a href="http://craftcookbook.net/recipes/330" rel="nofollow">http://craftcookbook.net/recipes/330</a>.  I also tried the groupBy plugin but had no success in getting that to output anything.</p>

CC BY-SA 3.0
2015-11-26T07:02:25.660Z
Is there only one category per entry, and if not, do you want to list the entry under each category assigned?
carlcs
<ordering><order>
Order Entries in a Section by Category Titles
# Order Entries in a Section by Category Titles

(Asked by: username_0 on 2015-11-25)

I currently have entries from a section output simply using a variable like:
{% set beer = craft.entries.section('beverages') %}

All of the beer entries have brands assigned to them using the category field.  How can I display the beer entries by brand? I use that beer variable throughout my templates for entry counts, filters, etc. I'd like to try and keep that in tact if possible.
I tried to use this but it seems to do more than what I need: http://craftcookbook.net/recipes/330.  I also tried the groupBy plugin but had no success in getting that to output anything.

**Tags:** ordering, order

> **Comments:**
> **username_1**: Is there only one category per entry, and if not, do you want to list the entry under each category assigned?  

---

## 1 answers

### Answer by username_0 on 2015-12-02. Score: 1

After some further research this http://craftcookbook.net/recipes/279 was a better fit for my needs.  The code I ended up using based on the link is below.
{% set beer = [] %}
{% set beerBrands = craft.categories.group('brandCategory').level(1).find() %}
    {% for category in beerBrands %}
         {% set beerRelatedCategories = craft.entries.section('beers').relatedTo(category).find() %}
         {% set beer = beer|merge(beerRelatedCategories) %}
    {% endfor %}


---

