<p>To exclude the current post use the current post's id with a <em>"not"</em> clause in the <code>id</code> query param.</p>

<pre><code>{% for relatedPost in craft.entries.relatedTo(entry.newsCategory).id('not ' ~ entry.id).limit(5).all() %}
</code></pre>

CC BY-SA 4.0
2018-08-10T20:37:46.133Z
Beauty!  Thank you!  If you don’t mind another question, where do you recommend people go to learn this sort of thing?
Eric A. Meyer
CC BY-SA 4.0
2018-08-10T20:39:19.243Z
Craft Stack Exchange is the usual place or asking on the Craft Slack channel. https://craftcms.com/community  The Craft community is very helpful.
a-am
CC BY-SA 4.0
2018-08-10T20:32:57.087Z
2018-08-16T20:59:02.283Z
2018-08-16T20:59:02.283Z
a-am
<p>In Craft 3, I’m trying to get the five most recent other posts sharing a category with the current post.  I got this far:</p>

<pre><code>{% for relatedPost in craft.entries.relatedTo(entry.newsCategory).limit(5) %}
</code></pre>

<p>That gets five posts sharing the current post’s category, <em>including</em> the current post if it happens to be recently posted.  How do I exclude the current post from the returned results, without just dropping it from the five so I’m only left with four?</p>

<craft3><categories><relatedto>
Get related posts excluding current post in Craft 3
# Get related posts excluding current post in Craft 3

(Asked by: username_0 on 2018-08-10)

In Craft 3, I’m trying to get the five most recent other posts sharing a category with the current post.  I got this far:
{% for relatedPost in craft.entries.relatedTo(entry.newsCategory).limit(5) %}

That gets five posts sharing the current post’s category, including the current post if it happens to be recently posted.  How do I exclude the current post from the returned results, without just dropping it from the five so I’m only left with four?

**Tags:** craft3, categories, relatedto

---

## 1 answers

### Answer by username_1 on 2018-08-10. Score: 8 | Accepted answer

To exclude the current post use the current post's id with a "not" clause in the id query param.
{% for relatedPost in craft.entries.relatedTo(entry.newsCategory).id('not ' ~ entry.id).limit(5).all() %}

> **Comments:**
> **username_0**: Beauty!  Thank you!  If you don’t mind another question, where do you recommend people go to learn this sort of thing?  
> **username_1**: Craft Stack Exchange is the usual place or asking on the Craft Slack channel. https://craftcms.com/community  The Craft community is very helpful.  

---

