I have a category set up and have added entries to it. How do I loop through these entries, and output just the title of each entry?

Serious noob here but trying to learn, any help would be gratefully received.

2 Answers 2


This example assumes you have your Category Group setup to use custom URLs. In the template used to display your categories, the category variable will be available and represent your CategoryModel for that page.

The key is to pass the CategoryModel (in our example below category) to the relatedTo parameter of the Entries tag.

{{ category.title }}

{% paginate craft.entries
    as entries 

    {% if entries|length %}

        {# Content #}
        {% for entry in entries %}
            {{ entry.title }}
        {% endfor %}

        {# Pagination #}

    {% else %}

        <p>No items have been added to this Category yet.</p>

    {% endif %}

{% endpaginate %}
  • Thanks Ben, this has allowed me to loop through all the entries in my channel (only have 1 as I'm using the personal version), I think I am missing something, maybe in the setup of my category group. I'll go back to it and have a root around, many thanks. Jul 5, 2014 at 9:57

Here's another good example for working with categories that may be useful to you. This will loop through all categories (that have entries) and show their entries:

{% set entries = craft.entries.section('someSection').limit(null) %}

{% for category in craft.categories.group('someCategoryGroup').relatedTo(entries) %}
    <h2>{{ category }}</h2>

    {% for entry in entries.relatedTo(category) %}
        {{ entry.title }}
    {% endfor %}

{% endfor %}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.