Category archive page isn't filtering by current category Ok all - this is bound to be ridiculously simple, as it's one of the most basic things you can do (https://craftcms.com/support/entries-related-to-category) - but I am ill and I can not figure out what I've done wrong.

I have a category group 'Things To Do'. That group is set to allow categories in it to have their own URLs. The URL format is: things-to-do/{slug} and it uses the template 'things-to-do/category'.

I also have a channel Things To Do, the URL format being 'things-to-do/{slug}' and using a different template 'things-to-do'.

If I go to the url for a category that exists, it loads the correct template and I can output the correct fields attached to the category itself; e.g., {{ category.title }} or {{ category.myCustomField }}

However, trying to output entries related to the category I'm viewing is instead just listing all entries regardless of their lack of association with the category...

{% set thingsToDo = craft.entries.relatedTo(category) %}
{% for thingToDo in thingsToDo %}
    ...
{% endfor %}


This should only be listing one entry for a given category, but it's listing all entries.

What have a screwed up?
Mystery solved; the relation code was too general; some of the entries were related to the category on the homepage, and the example code doesn't care about how or where the entries are related to the category as long as they are somewhere somehow.

I needed to be more specific:

{% set thingsToDo = craft.entries.relatedTo({
    targetElement: category,
    field: 'typeOfThing'
}) %}


Works.