All lives can’t matter until black lives matter. (2024)

Show All Posts from All Blogs in Chronological Order in a Shopify Liquid template

According to my research Shopify’s suggestion for implementing categories is to create a separate blog for each Category. Then, if you want to show all posts from all blogs you have to loop through each blog’s articles, one blog at a time, resulting in a list of all Blog 1, then all Blog 2, etcetera.

A client wanted to show all posts from all categories/blogs in one chronological list. Searching online I couldn’t find any code that did this so I wrote something myself. It does require you to add your blog/category handles, but this is a feature! 🤣 You have control over which blogs/categories are included.

As you'll see, first a list of "identifiers" for all articles is created using a loop, then that list is sorted so the most recent articles are first. Finally a loop outputs all the articles. In this example a limit of 20 is set but you can change that for your own purposes.

{% comment %} 
Generate list of mixed articles from all listed blogs, sorted by publish date.
Add the blog handles you want to include in the output, as many as you need.
{% endcomment %}
{% assign all_blogs = "blogHandle1,blogHandle2,blogHandle3" | split: "," %}
{% assign article_list = "" | split: "," %}
{% assign delimiter = "___" %}
{% for blog_handle in all_blogs %}
  {%- for item in blogs[blog_handle].articles -%}
    {% assign identifier = item.published_at | date: "%Y-%m-%d-%H-%M-%S" | append: delimiter | append: item.handle | split: " " %}
    {% assign article_list = article_list | concat: identifier %}
  {%- endfor -%}
{%- endfor -%}
{% assign article_list = article_list | sort_natural | reverse %}

{% comment %} 
Create markup for posts 
{% endcomment %}
<!-- any container start markup -->
{% for identifier in article_list limit:20 %}
  {% assign identifierParts = identifier | split: delimiter %}
  {% comment %} Get post from global articles object, using the "handle"/URI {% endcomment %}
  {% assign item = articles[identifierParts[1]] %}
  <!-- your per-post markup with variables like item.title, item.url, item.image, etcetera -->
  <!-- {{ identifier }} -->
{%- endfor -%}
<!-- any container end markup -->

I hope this helps someone! If it helps you I'd love to hear about it.


Have a question or comment about this post, or just want to say hi? Drop me a line


Earlier Post: Add markup to a Squarespace Order Status page only if it is the first view

Later Post: In it to grin it :-)

All Posts