Outputting .relatedTo() total entries number
The best way to do it depends on whether you actually want to loop through the related entries or not.

If you only want the total, and aren’t going to be looping through them, use .total():



{% set entryCount = craft.entries.section('products').relatedTo(category).total() %}


(Note that’s just .total(), not .find().total().)

That way you’re not making Craft do any more work than what you actually need - just figuring out the total related entries.

If you do want to loop through them as well, then grab the entries normally and then figure out how many came back using Twig’s |length filter:

{% set entries = craft.entries.section('products').relatedTo(category) %}
{% set entryCount = entries|length %}

{% for entry in entries %}
    ...
{% endfor %}