# Using selectattr/rejectattr with blog\_popular\_posts's objects

**URL:** <https://community.hubspot.com/t/using-selectattr-rejectattr-with-blog-popular-postss-objects/42838>\
**Category:** CMS Development\
**Tags:** design-manager\
**Created:** [August 25, 2021, 7:00am UTC](https://community.hubspot.com/t/using-selectattr-rejectattr-with-blog-popular-postss-objects/42838 "2021-08-25T07:00:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![xavianaxw](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/xavianaxw/32/60590_2.png) [@xavianaxw](https://community.hubspot.com/u/xavianaxw)\
**Post date:** [August 25, 2021, 7:00am UTC](https://community.hubspot.com/t/using-selectattr-rejectattr-with-blog-popular-postss-objects/42838/1 "2021-08-25T07:00:30Z")

</div>

I’m trying to create a recomended carousel where I’m fetching all blog posts from a particular tag using the **blog\_popular\_posts** function. Here’s my code right now.

`{% set posts = blog_popular_posts(group.id, 11, 'Animation') %}`

So while this is all working, it also does include the ‘current’ page blog post and I’m trying to exclude it using the [**rejectattr**](https://developers.hubspot.com/docs/cms/hubl/filters#rejectattr) or **[selectattr](https://developers.hubspot.com/docs/cms/hubl/filters#selectattr)** filter. Here’s how my code look like now.

```lia-code-sample
{% set posts = blog_popular_posts(group.id, 11, 'Animation') %}
{% set posts = posts|rejectattr('absolute_url', 'equalto', content.absolute_url %}

```

I’m expecting it to return all the posts except the post that belongs to the current page I’m on but it’s not returning me anything.

---

For reference, here is what **blog\_popular\_posts** returns

`(SizeLimitingPyList: [BlogPost 53605467259 Horror Creatures with Molly Brown, BlogPost 53675010744 Test webinar, BlogPost 53608133921 Part 1: Creating Assets and Understanding What Sells, BlogPost 53605467691 Part 2: How to Package, Price, and Sustain Your Business])`

which i’m assuming are objects that should work with the **selectattr** and **rejectattr** filters?

---

<div class="post-metadata">

**Author:** ![piersg](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/piersg/32/99782_2.png) [@piersg](https://community.hubspot.com/u/piersg)\
**Post date:** [August 25, 2021, 9:14am UTC](https://community.hubspot.com/t/using-selectattr-rejectattr-with-blog-popular-postss-objects/42838/2 "2021-08-25T09:14:45Z")

</div>

It will work if you loop over posts to filter out the current blog’s url with an if statement e.g.

```lia-code-sample
{% set posts = blog_popular_post(group.id, 11, 'Animation') %}
{% for post in posts %}
 {% if post.absolute_url != content.absolute_url %}
 <div class="popular-posts"><a href="{{ post.absolute_url }}">{{ post.name }}</a></div>
 {% endif %}
{% endfor %}

```

---

<div class="post-metadata">

**Author:** ![xavianaxw](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/xavianaxw/32/60590_2.png) [@xavianaxw](https://community.hubspot.com/u/xavianaxw)\
**Post date:** [August 25, 2021, 11:34pm UTC](https://community.hubspot.com/t/using-selectattr-rejectattr-with-blog-popular-postss-objects/42838/3 "2021-08-25T23:34:42Z")

</div>

Yeah that works but I just wanted to use selectattr and rejectattr so i can filter out objects that have matching absolute\_url with the page I’m on so that i can conditionally render other html with it as well.

---

<div class="post-metadata">

**Author:** ![xavianaxw](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/xavianaxw/32/60590_2.png) [@xavianaxw](https://community.hubspot.com/u/xavianaxw)\
**Post date:** [August 26, 2021, 2:30am UTC](https://community.hubspot.com/t/using-selectattr-rejectattr-with-blog-popular-postss-objects/42838/4 "2021-08-26T02:30:36Z")

</div>

For some reason it doesn’t work with **absolute\_url** but it works i

```lia-code-sample
{% set posts = blog_popular_posts(group.id, 11) %}
{% set posts = posts|rejectattr('slug', 'equalto', content.slug) %}

```

😪

f i use other properties like **name** or **slug.** I’ve got it to work with
