Shopify: Show latest articles from all blogs
Posted on April 4, 2022 by jamie
{% comment %} First add all the handles of the blogs you want to include. In this example I just use my own two blogs - works and news. {% endcomment %} {% assign featuredBlogs = 'works,news' | split:',' %} {% comment %} Set the featuredArticles variable to false by default. {% endcomment %} {% assign featuredArticles = false %} {% comment %} Grab the last 50 (default) articles from each Blog. Add the articles to the featureArticles variable. {% endcomment %} {% for featuredBlog in featuredBlogs %} {% if blogs[featuredBlog].articles %} {% if featuredArticles %} {% assign featuredArticles = featuredArticles | concat:blogs[featuredBlog].articles %} {% else %} {% assign featuredArticles = blogs[featuredBlog].articles %} {% endif %} {% endif %} {% endfor %} {% comment %} If featuredArticles is not false we should have articles to show - so let's do it! {% endcomment %} {% if featuredArticles %} {% assign featuredArticles = featuredArticles | sort:'published_at' | reverse %} {% comment %} Now a quick example of showing the latest 10 articles from our master article list {% endcomment %} {% for article in featuredArticles limit:10 %} <p><b>{{ article.title }}: </b><br>{{ article.published_at }}</p> {% endfor %} {% endif %}
https://freakdesign.com.au/blogs/news/105090695-show-the-latest-shopify-articles-from-all-blogs