Craft CMS Stack Exchange is a question and answer site for administrators, end users, developers and designers for Craft CMS. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 6 down vote accepted

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 %}
share|improve this answer
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. – bobbyballbags Jul 5 '14 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'someCategoryGroup').relatedTo(entries) %}
    <h2>{{ category }}</h2>

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

{% endfor %}
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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