# Using blog\_recent\_topic\_posts() to Exclude Current Post in Returned Results

**URL:** <https://community.hubspot.com/t/using-blog-recent-topic-posts-to-exclude-current-post-in-returned-results/45096>\
**Category:** CMS Development\
**Created:** [October 8, 2021, 5:52pm UTC](https://community.hubspot.com/t/using-blog-recent-topic-posts-to-exclude-current-post-in-returned-results/45096 "2021-10-08T17:52:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![CFrench](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/cfrench/32/102945_2.png) [@CFrench](https://community.hubspot.com/u/CFrench)\
**Post date:** [October 8, 2021, 5:52pm UTC](https://community.hubspot.com/t/using-blog-recent-topic-posts-to-exclude-current-post-in-returned-results/45096/1 "2021-10-08T17:52:43Z")

</div>

Hi,

I created a recent posts module for the bottom of my blog to pull in the three most recent posts from the same topic as the present post. I like the way it’s working, but… the first post is the current post.  
So is there a way to add in an offset to take posts #2, #3 and #4 and/or exlcude the current post?  
Here’s the gist of the module:

```lia-code-sample
{% set number_of_posts = 3 %}
{% set posts = blog_recent_topic_posts("default", content.topic_list[0].slug, 3) %}
{% if module.specific_tag_topic %}
	{% set posts = blog_recent_topic_posts(module.choose_blog, module.tag, number_of_posts) %}
{% endif %}

<section class="blog-feed">
 <div>
 <h2>
 Related Reading
 </h2>
 </div>
 <div class="blog-posts">
 {% for post in posts %}
 <div class="blog-post">
 <div class="ni-post blog-post-inner">
 <div class="blog-post-image" style="background-image: url({{ resize_image_url( post.featured_image,0,350 ) }});"></div>
 <div class="blog-post-content-wrapper">
 <a class="blog-post-title" href="{{ post.absolute_url }}"><h3>{{ post.name }}</h3></a>
 <a class="blog-post-read-more" href="{{ post.absolute_url }}">Read More →</a>
 </div>
 </div>
 </div>
 {% endfor %}
 </div>
</section>

```

---

<div class="post-metadata">

**Author:** ![Teun](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/teun/32/28739_2.png) [@Teun](https://community.hubspot.com/u/Teun)\
**Post date:** [October 9, 2021, 8:00am UTC](https://community.hubspot.com/t/using-blog-recent-topic-posts-to-exclude-current-post-in-returned-results/45096/2 "2021-10-09T08:00:17Z")

</div>

If you fetch 4 posts instead of 3, you can use an if statement to filter out the current post using the name of the post.

{% if post.name != content.name %}

---

<div class="post-metadata">

**Author:** ![erod](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/erod/32/99705_2.png) [@erod](https://community.hubspot.com/u/erod)\
**Post date:** [October 10, 2021, 7:02am UTC](https://community.hubspot.com/t/using-blog-recent-topic-posts-to-exclude-current-post-in-returned-results/45096/3 "2021-10-10T07:02:24Z")

</div>

Similar to what @Teun said but instead of doing content.name you do a range. Below should work.

```lia-code-sample
{% set number_of_posts = 3 %}
{% set posts = blog_recent_topic_posts("default", content.topic_list[0].slug, 4) %}
{% if module.specific_tag_topic %}
	{% set posts = blog_recent_topic_posts(module.choose_blog, module.tag, number_of_posts) %}
{% endif %}

<section class="blog-feed">
 <div>
 <h2>
 Related Reading
 </h2><br>
 </div>
 <div class="blog-posts">
 {% for post in posts %}
 {% if loop.index in range(2,99) %}
 <div class="blog-post">
 <div class="ni-post blog-post-inner">
 <div class="blog-post-image" style="background-image: url({{ resize_image_url( post.featured_image,0,350 ) }});"></div>
 <div class="blog-post-content-wrapper">
 <a class="blog-post-title" href="{{ post.absolute_url }}"><h3>{{ post.name }}</h3></a>
 <a class="blog-post-read-more" href="{{ post.absolute_url }}">Read More →</a>
 </div>
 </div>
 </div>
 {% endif %}
 {% endfor %}
 </div>
</section>

```
