[Hubspot Hubl] Different ways of pulling blog posts into blog post thumbnails.
List the most recents posts on the blog page currently being viewed.
{% if is_listing_view and not last_page_num %}
<section class="blog-thumbs">
{% for content in contents[0:3] %}
<a href="{{ content.absolute_url }}" style="background: url({{ content.featured_image }}) center no-repeat; background-size: cover;" class="blog-thumbs__post">
<p class="blog-thumbs__title">{{ content.name }}</p>
</a>
{% endfor %}
</section>
{% endif %}
Pull most recent posts from blog; can be used on landing pages.
{% set posts = blog_recent_posts('default', 3) %}
{% for post in posts %}
<div class="post">
<p>
<a href="{{ post.absolute_url }}" target="blank">
<img src="{{ post.featured_image }}" />
</a>
</p>
<h3>
<a href="{{ post.absolute_url }}" target="_blank">{{ post.name }}</a>
</h3>
<p>By {{ post.blog_post_author }}, {{ post.publish_date_localized }}</p>
<p>
<a href="{{ post.absolute_url }}" target="_blank">Read >></a>
</p>
</div>
{% endfor %}
Pull most recent posts related to the post currently being viewed.
{% set related_posts = blog_recent_topic_posts("default", content.topic_list[0].slug, 2) %}
{% if related_posts|length > 0 %}
<div class="related-post">
{% for post in related_posts %}
{% set thumb = post.widgets.listing_thumb.body.src or post.featured_image %}
{% set url = post.widgets.resource_url.body.value or post.absolute_url %}
<a href="{{ url }}" class="resource-tile">
{% if thumb %}
<div><img src="{{ post.featured_image }}" alt="" class="resource-tile__thumb"></div>
{% endif %}
<h4 class="resource-tile__title">{{ post.name }}</h4>
</a>
{% endfor %}
</div>
{% endif %}
Pull most recent blog posts from a designated topic.
{% set nutrition_posts = blog_recent_topic_posts('default', 'nutrition', 1) %}
{% for topic_post in nutrition_posts %}
<a href="{{ topic_post.absolute_url }}">
<div class="topic-post nutrition" style="background: url('{{ topic_post.post_list_summary_featured_image }}') center no-repeat;">
<div class="topic-text">
<span>Nutrition</span>
<p class="date">{{ topic_post.publish_date|datetimeformat('%B %Y') }}</p>
<p>{{ topic_post.name }}</p>
</div>
</div>
</a>
{% endfor %}