CMS Development

ekt
Teilnehmer/-in

Print set of not default blog posts

lösung

Hi guys,
I need to show a set of blog posts on a page, that is not a blog template. I have several blogs, so I need to show posts from the exact one. This code shows posts from 'default' blog. Where to find something like blog's id so I'll be able to use this code. 

{% set posts = blog_recent_posts('default', 5) %}
{% for post in posts %}
    <h3><a href="{{ post.absolute_url }}">{{ post.name }}</a></h3>
    <img src="{{ post.featured_image }}" alt="{{ post.name }}">
{% endfor %} 

 

0 Upvotes
2 Akzeptierte Lösungen
Blake32
Lösung
Teilnehmer/-in

Print set of not default blog posts

lösung

Each blog had a unique ID, you can find each one on the blog ID page. it's the set of numbers after /blog/ in the URL. Put that number in place of Default and it will only pull posts from that blog.

Lösung in ursprünglichem Beitrag anzeigen

dennisedson
Lösung
HubSpot-Produktteam
HubSpot-Produktteam

Print set of not default blog posts

lösung

@ekt ,to extend on @Blake32 

When you are on the blog listing in the backend you will see something like this in your url

https://app.hubspot.com/blog/XXXXXXX/blogs/THISISTHEBLOGID/manage/posts/all

 

so instead of default you would replace that with th e"THISISTHEBLOGID" digits

{% set posts = blog_recent_posts('THISISTHEBLOGID', 5) %}

Lösung in ursprünglichem Beitrag anzeigen

4 Antworten
dennisedson
Lösung
HubSpot-Produktteam
HubSpot-Produktteam

Print set of not default blog posts

lösung

@ekt ,to extend on @Blake32 

When you are on the blog listing in the backend you will see something like this in your url

https://app.hubspot.com/blog/XXXXXXX/blogs/THISISTHEBLOGID/manage/posts/all

 

so instead of default you would replace that with th e"THISISTHEBLOGID" digits

{% set posts = blog_recent_posts('THISISTHEBLOGID', 5) %}
Blake32
Lösung
Teilnehmer/-in

Print set of not default blog posts

lösung

Each blog had a unique ID, you can find each one on the blog ID page. it's the set of numbers after /blog/ in the URL. Put that number in place of Default and it will only pull posts from that blog.

ekt
Teilnehmer/-in

Print set of not default blog posts

lösung

thanks for help!

0 Upvotes
Blake32
Teilnehmer/-in

Print set of not default blog posts

lösung

meant to say you can find it when you're on the blog admin page, not ID page.