<p>If you don't mind using the search parameter you could add it like this:</p>

<pre><code>{% set beer = 'a' %}
{% set allCats = craft.categories.search('title:' ~ beer ~ '*').limit(null) %}
</code></pre>

CC BY-SA 3.0
2014-11-17T17:57:33.783Z
Upvoted for your use of 'beer'.
Steve Abraham
CC BY-SA 3.0
2014-11-17T17:35:11.217Z
2014-11-17T17:35:11.217Z
carlcs
<p>I'm attempting to pull out a list of categories starting with certain letter(s).</p>

<p>What I've come up with so far seems a little excessive and I'm wondering if I've missed something obvious.</p>

<p>Can it all be done with just the 'craft.categories...' line?</p>

<pre><code>{% set allCats = craft.categories.group('listingCategories').order('title').limit(null).find() %}
{% set allCatsByLetter = allCats|group('title | first') %}

{% for letter, allCats in allCatsByLetter if letter == "A" %}
    &lt;ul&gt;
        {% for cat in allCats %}
            &lt;li&gt;{{ cat.title }}&lt;/li&gt;
        {% endfor %}
    &lt;/ul&gt;
{% endfor %}
</code></pre>

CC BY-SA 3.0
2014-11-17T17:41:29.913Z
I like this approach better then mine using search, Steve!
carlcs
<templating><categories><array>
Selecting categories by first letter
# Selecting categories by first letter

(Asked by: username_0 on 2014-11-17)

I'm attempting to pull out a list of categories starting with certain letter(s).
What I've come up with so far seems a little excessive and I'm wondering if I've missed something obvious.
Can it all be done with just the 'craft.categories...' line?
{% set allCats = craft.categories.group('listingCategories').order('title').limit(null).find() %}
{% set allCatsByLetter = allCats|group('title | first') %}

{% for letter, allCats in allCatsByLetter if letter == "A" %}
    
        {% for cat in allCats %}
            {{ cat.title }}
        {% endfor %}
    
{% endfor %}

**Tags:** templating, categories, array
> **Comments:**
> **username_1**: I like this approach better then mine using search, Steve!  

---

## 1 answers

### Answer by username_1 on 2014-11-17. Score: 2

If you don't mind using the search parameter you could add it like this:
{% set beer = 'a' %}
{% set allCats = craft.categories.search('title:' ~ beer ~ '*').limit(null) %}

> **Comments:**
> **username_0**: Upvoted for your use of 'beer'.  

---

