# Passing a variable into blog\_post\_by\_id ?

**URL:** <https://community.hubspot.com/t/passing-a-variable-into-blog-post-by-id/4053>\
**Category:** CMS Development\
**Created:** [December 3, 2017, 9:57pm UTC](https://community.hubspot.com/t/passing-a-variable-into-blog-post-by-id/4053 "2017-12-03T21:57:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![andreasmb](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/andreasmb/32/44643_2.png) [@andreasmb](https://community.hubspot.com/u/andreasmb)\
**Post date:** [December 3, 2017, 9:57pm UTC](https://community.hubspot.com/t/passing-a-variable-into-blog-post-by-id/4053/1 "2017-12-03T21:57:45Z")

</div>

Hi there,

I’m trying create a page where my marketing colleagues can insert a specific post from any of our blogs. A great to way to achieve this seems to be to use “blog\_post\_by\_id”, like this :

```auto
{% text "post_id" label="Post's - ID number", export_to_template_context=True %}

{% set post = blog_post_by_id( {{ post_id }} ) %}

```

Sadly, this doesn’t seem to work, and Hubspot’s documentation indicates that the function only accepts a numeric ID. Seems like an odd limitation.  
Does anybody know a workaround? Or perhaps I’ve misunderstood what the blog\_post\_by\_id function does, and there’s actually a way to do this.  
I know I could use a for loop and iterate through a bunch of posts until I find the one with the ID I’m looking for, but that seems very tedious, especially given that I’m fetching posts from multiple different blogs.

---

<div class="post-metadata">

**Author:** ![andreasmb](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/andreasmb/32/44643_2.png) [@andreasmb](https://community.hubspot.com/u/andreasmb)\
**Post date:** [December 3, 2017, 10:28pm UTC](https://community.hubspot.com/t/passing-a-variable-into-blog-post-by-id/4053/2 "2017-12-03T22:28:50Z")

</div>

Ah, it looks like I got my syntax wrong – here is how it should be formatted:

```auto
{% text "post_id" label="Post's - ID number", export_to_template_context=True %}

{% set post = blog_post_by_id(post_id.value) %}

```
