I'm new to this, so sorry if this is really basic.

I want to display a list of entries in the same category as the main entry in my template, excluding the current entry.

This is my code:

{% for category in entry.tutorialCategory.all() %}
{% for tutorial in craft.entries
   .id('not ' ~ entry.id) %}
       <a href="{{ tutorial.url }}">{{ tutorial.title }}</a>
{% else %}
       There are currently no related tutorials.
{% endfor %}
{% endfor %}

I always get the 'There are currently no related tutorials.' message though.

Any suggestions on where I'm going wrong?

  • 1
    You might have other issues but first thing I see is the .all() should be at the end, not before the .id clause – Seb Nov 5 '19 at 15:39
  • That, was it, thanks Seb! – Jon Nov 5 '19 at 16:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.