Skip to content

Instantly share code, notes, and snippets.

@thetwopct
Created January 14, 2024 10:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thetwopct/9605e98c8a9274b18df06acab1206ae1 to your computer and use it in GitHub Desktop.
Save thetwopct/9605e98c8a9274b18df06acab1206ae1 to your computer and use it in GitHub Desktop.
HubL - Get multiple blogs, display together, order by published date
{# Create a variable to collect all posts #}
{% set all_posts = [] %}
{# Loop through all posts selected in the blog field #}
{% for item in module.blogs.selected %}
{# Get posts for each blog #}
{% set posts = blog_recent_posts(item, 200) %}
{# Append each post to the all_posts array #}
{% for post in posts %}
{% do all_posts.append( post ) %}
{% endfor %}
{% endfor %}
{% for post in all_posts[:5]|sort(true, false, 'published_at') %}
<article class="blog-post" aria-label="Blog post summary: {{ post.name }}">
<p class="blog-post__title"><a href="{{ post.absolute_url }}">{{ post.name }}</a></p>
</article>
{% endfor %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment