Skip to content

Instantly share code, notes, and snippets.

@apsolut
Last active October 1, 2024 18:03
Show Gist options
  • Save apsolut/4bf16df52f65b3495e39d46a9726dfdb to your computer and use it in GitHub Desktop.
Save apsolut/4bf16df52f65b3495e39d46a9726dfdb to your computer and use it in GitHub Desktop.
HubSpot get posts on page - landing page
<div class="post-showcase">
{% set post_ids = [] %}
{% for post_item in module.posts %}
{% do post_ids.append(post_item.post_id) %}
{% endfor %}
{% set contents = content_by_ids(post_ids) %}
{% for content in contents %}
<div class="post-item">
{% if content.featuredImage %}
<img src="{{ content.featuredImage }}" alt="{{ content.name }}" class="post-image">
{% endif %}
<h2 class="post-title">
<a href="{{ content.absolute_url }}">{{ content.name }}</a>
</h2>
</div>
{% endfor %}
</div>
<div class="post-showcase" >
{% for post_item in module.posts %}
{% set post = blog_post_by_id(post_item.post_id) %}
{% if post %}
<div class="post-item">
{{ post }}
{% if post.featured_image %}
<img src="{{ post.featured_image }}" alt="{{ post.name }}" class="post-image">
{% endif %}
<h2 class="post-title">
<a href="{{ post.absolute_url }}">{{ post.name }}</a>
</h2>
</div>
{% endif %}
{% endfor %}
</div>
{% set contents = content_by_ids([179840588455, 179494974230, 179494974111]) %}
<ul>
{% for content in contents %}
<li>
<a href="{{ content.absolute_url }}">{{content.title}}</a>
</li>
{% endfor %}
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment