<p>You probably kind of confuse your "apprenticeships categories" with your "apprenticeships" section. Try something like this instead:</p>

<pre><code>{% set relatedEntries = craft.entries({
    section: apprenticeships,
    id: 'not ' ~ entry.id,
    relatedTo: {
        targetElement: entry.apprenticeshipsCatsField
    }
}) %}
</code></pre>

<p>You now want to order them by your categories? Have a look at my answer I just posted here: <a href="https://craftcms.stackexchange.com/q/11944/125">"How do I display entries, grouped by distinct categories..."</a>.</p>

CC BY-SA 3.0
2015-10-16T12:26:12.757Z
No. It was a different problem. Combined with a late night and rushing to get something done before I went out I was working with the wrong bit of the template. My original idea worked once I'd put it in the correct place.
foamcow
CC BY-SA 3.0
2015-10-16T13:00:02.700Z
Different problem? Changing "apprenticeshipsCats" to "apprenticeships" (or "vacancies" – I didn't know your channel handle) looks like exactly what you did in the end?!
carlcs
CC BY-SA 3.0
2015-10-16T09:04:35.613Z
2015-10-16T09:04:35.613Z
2017-04-13T12:51:00.200Z
carlcs
<p>On my template I am showing detail of an entry.
Beneath this I am showing a list of other entries that share the same kind of category relationship as the entry being viewed.</p>

<p>This list currently includes the entry being viewed and I wish to omit that from the list.</p>

<p>I'm retrieving the entries like so:</p>

<pre><code>{% for category in craft.entries.section('apprenticeshipsCats').relatedTo(entry).id('not ' ~ entry.id) %}
</code></pre>

<p>and had expected the 'not' parameter to do what I wanted but it doesn't seem to be working. entry.id is outputting the correct ID and even if I hardcode the entry id then it still appears in the list.</p>

CC BY-SA 3.0
2015-10-16T08:54:58.850Z
Do you want to list entries from your "apprenticeships" or "apprenticeships categories" section?
carlcs
CC BY-SA 3.0
2015-10-16T12:15:05.340Z
I'm listing entries from the apprenticeships channel. It's all working fine except for being able to omit the apprenticeship entry which is currently viewed.
foamcow
CC BY-SA 3.0
2015-10-16T12:25:09.500Z
Ha! I'd actually done it correctly but applied by 'not' criteria to the wrong craft.entries loop. Like an idiot. I'm so amateur!
foamcow
CC BY-SA 3.0
2015-10-16T13:01:18.353Z
Like I said, wrong section. Compare the solution in your update to what I posted. You notice something?
carlcs
<entries><relations>
Omitting current entry from list of entries generated from a relationship
# Omitting current entry from list of entries generated from a relationship

(Asked by: username_0 on 2015-10-16)

On my template I am showing detail of an entry.
Beneath this I am showing a list of other entries that share the same kind of category relationship as the entry being viewed.
This list currently includes the entry being viewed and I wish to omit that from the list.
I'm retrieving the entries like so:
{% for category in craft.entries.section('apprenticeshipsCats').relatedTo(entry).id('not ' ~ entry.id) %}

and had expected the 'not' parameter to do what I wanted but it doesn't seem to be working. entry.id is outputting the correct ID and even if I hardcode the entry id then it still appears in the list.

**Tags:** entries, relations
> **Comments:**
> **username_1**: Do you want to list entries from your "apprenticeships" or "apprenticeships categories" section?  
> **username_0**: I'm listing entries from the apprenticeships channel. It's all working fine except for being able to omit the apprenticeship entry which is currently viewed.  
> **username_0**: Ha! I'd actually done it correctly but applied by 'not' criteria to the wrong craft.entries loop. Like an idiot. I'm so amateur!  
> **username_1**: Like I said, wrong section. Compare the solution in your update to what I posted. You notice something?  

---

## 1 answers

### Answer by username_1 on 2015-10-16. Score: 1 | Accepted answer

You probably kind of confuse your "apprenticeships categories" with your "apprenticeships" section. Try something like this instead:
{% set relatedEntries = craft.entries({
    section: apprenticeships,
    id: 'not ' ~ entry.id,
    relatedTo: {
        targetElement: entry.apprenticeshipsCatsField
    }
}) %}

You now want to order them by your categories? Have a look at my answer I just posted here: "How do I display entries, grouped by distinct categories...".

> **Comments:**
> **username_0**: No. It was a different problem. Combined with a late night and rushing to get something done before I went out I was working with the wrong bit of the template. My original idea worked once I'd put it in the correct place.  
> **username_1**: Different problem? Changing "apprenticeshipsCats" to "apprenticeships" (or "vacancies" – I didn't know your channel handle) looks like exactly what you did in the end?!  

---

