CMS Development

Blake32
Participant

If statement with blogid

I am looking for a way to use the Hubl Print Recent Posts function, but instead of using the default blog I would like to use an if statement to only print the recent posts from that blog. Is there a way to do an if statement with a blog id?

 

{% if blogid='12345678910' %}
<!-- Print Recent Posts for first blog -->
{% elif blogid='10987654321 %}
<!-- Print Recent Posts for second blog -->
1 Réponse
lscanlan
Ancien salarié HubSpot
Ancien salarié HubSpot

If statement with blogid

Hi @Blake32,

 

Is there a reason you need to do that with an if statement? The first parameter of that function actually takes the blog ID. Using the "default" keyword just forces the function to use the blog that you're currently visiting. So for example if you wanted to pull posts from blog ID 12345678910, you'd just use the blog_recent_posts() function like so:

 

blog_recent_posts(12345678910, 5)

 

Or if you wanted to pull posts from blog ID 10987654321, you'd just use the function like so:

 

blog_recent_posts(10987654321, 5)

 

Does that help? Let me know if you have any questions about it.

 

Leland Scanlan

HubSpot Developer Support
0 Votes