blog_recent_posts not pulling in posts from specified blog

Hi,

I’ve created a “Portfolio” blog in Hubspot, which is used to contain portfolio posts. These posts are separate from our regular blog posts.

I’m trying to use the blog_recent_posts function to bring in the 6 most recent portfolio posts, however it doesn’t seems to be working as intended.

eg,

{% set posts = blog_recent_posts(‘portfolio’, 6) %}

brings in posts from the default blog, and not from the portfolio blog. It is basically the same as

{% set posts = blog_recent_posts(‘default’, 6) %}

Is there something I can do so that it will fetch posts from ‘portfolio’ instead of the default blog?

Thanks!

Hey @joetan54 instead of “portfolio” in your code here:

{% set posts = blog_recent_posts(‘portfolio’, 6) %}

you’d want to use your blog’s ID. So it would look like this with your ID in place of “YOUR BLOG ID”:

{% set posts = blog_recent_posts(‘YOUR BLOG ID’, 6) %}

You can get the ID for your blog from the URL in the editor by going to your blog dashboard (Marketing > Website > Blog > Choose the Portfolio blog in the list of blogs in the top left corner). It will be the set of numbers after “/blogs/” in the URL.

That works great, thank you!

Happy to hear that is working for you! No problem at all.

I can not see any change in the URL when I select other blogs, it stays the same like this: Blog | HubSpot
no matter which blog I select from the above dropdown? What to do?

Hey @AWebDev,

You should be able to navigate here: Settings > Website > Blog and then use the blog switcher dropdown on the top of the options to select the blog. From there, you should then see the URL change with the proper blog id.

Using that ID should do the trick for you :slightly_smiling_face:

-AJ

FYI in 2023 this no longer works - I am digging and digging to find my blog’s ID that isn’t the default, and it’s nowhere to be found in the URL or anywhere else that I can find.