Just getting starting with templating so apologies if this is obvious. Couldn't find a solution through search.

I have set up two sections. These contain different sets of information.

I have one category group that lists UK counties like so..

Country (Parent) - County (Child) - County (Child) - County (Child)

Both sections have this category group as a category field.

Now I want to create a Category page, but that only lists the entries for the section you are currently viewing.

Lets say for example you are viewing a list of entries, or single entry in section 1. On an index page I'm displaying the category like so..

{% for category in entry.county.level(2) %}<a href="#">{{ category.title }}{% endfor %}

and on a single page like so...

{% set category = entry.county.last() %} <a href="#">{{ category.title }}</a>

Now I want to link to the category page plate that will show a list of entries within that category.

I have my category group set up like so...


Now I'm not quite sure how to set this up so that it will only show the relevant sections entries.

Does that make sense?

Please ask if it's not clear and I can hopefully clarify!


1 Answer 1


I'd say you want to look at the relations https://craftcms.com/docs/relations#the-relatedTo-param

You would then use craft.entries.section( 'sectionHandle' ).relatedTo( category ) to grab all entries related to the category you are viewing.

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.