<p>Your mistake is in getting the category. Instead of what you have try:</p>

<pre><code>{% set category = craft.categories.group('allcategories').slug('photos').find() %}
</code></pre>

<p>Getting elements in Craft use ElementCriteriaModel and <code>find()</code>, <code>first()</code>, <code>last()</code>, &amp;c. do not accept any parameters (though <code>nth()</code> is an exception to this). So you need to search by other fields in the element as per the <a href="https://craftcms.com/docs/templating/elementcriteriamodel#setting-the-parameters">docs</a>.</p>

<p>You may also want to make sure that the slug of the category group is not camel case (<code>allCategories</code> as opposed to <code>allcategories</code>).</p>

CC BY-SA 3.0
2016-01-04T01:31:49.787Z
2016-01-04T01:31:49.787Z
Bryan Redeagle
<p>I've got a category group called <code>allcategories</code>, inside of this is two categories called <code>design</code> and <code>photo</code>.</p>

<p>I'm trying to filter all entries in the section <code>projects</code> by the category `photo' but none of my permutations are working :(</p>

<pre><code>&lt;section class="index"&gt;

    {% set category = craft.categories.group('allcategories').find('photos') %}
    {% set projects = craft.entries.section('projects').relatedTo(category).find() %}

    {% for entry in projects %}
        &lt;p&gt;&lt;a href="{{ entry.url }}"&gt;{{ entry.title }}&lt;/a&gt;&lt;/p&gt;
    {% endfor %}

&lt;/section&gt;
</code></pre>

<categories><category>
How to display all entries within a given category
# How to display all entries within a given category

(Asked by: username_0 on 2016-01-04)

I've got a category group called allcategories, inside of this is two categories called design and photo.
I'm trying to filter all entries in the section projects by the category `photo' but none of my permutations are working :(


    {% set category = craft.categories.group('allcategories').find('photos') %}
    {% set projects = craft.entries.section('projects').relatedTo(category).find() %}

    {% for entry in projects %}
        {{ entry.title }}
    {% endfor %}

**Tags:** categories, category

---

## 1 answers

### Answer by username_1 on 2016-01-04. Score: 5

Your mistake is in getting the category. Instead of what you have try:
{% set category = craft.categories.group('allcategories').slug('photos').find() %}

Getting elements in Craft use ElementCriteriaModel and find(), first(), last(), &c. do not accept any parameters (though nth() is an exception to this). So you need to search by other fields in the element as per the docs.
You may also want to make sure that the slug of the category group is not camel case (allCategories as opposed to allcategories).


---

