<p>I'm new to this, so sorry if this is really basic.</p>

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

<p>This is my code:</p>

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

<p>I always get the 'There are currently no related tutorials.' message though.</p>

<p>Any suggestions on where I'm going wrong?</p>

CC BY-SA 4.0
2019-11-05T15:39:25.857Z
You might have other issues but first thing I see is the `.all()` should be at the end, not before the `.id` clause
Seb
CC BY-SA 4.0
2019-11-05T16:11:12.737Z
That, was it, thanks Seb!
Jon
<categories><relatedto>
Showing entries in same category, excluding the current entry
# Showing entries in same category, excluding the current entry

(Asked by: username_0 on 2019-11-04)

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
   .section('tutorials')
   .relatedTo(category).all()
   .id('not ' ~ entry.id) %}
       {{ tutorial.title }}
{% 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?

**Tags:** categories, relatedto

> **Comments:**
> **username_1**: You might have other issues but first thing I see is the `.all()` should be at the end, not before the `.id` clause  
> **username_0**: That, was it, thanks username_1!  

---

## 0 answers

