Created
January 14, 2024 10:31
-
-
Save thetwopct/9605e98c8a9274b18df06acab1206ae1 to your computer and use it in GitHub Desktop.
HubL - Get multiple blogs, display together, order by published date
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{# 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