Skip to content

Instantly share code, notes, and snippets.

@kyleaparker
Last active October 5, 2023 19:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kyleaparker/b9fd3e4f7532f9f19658 to your computer and use it in GitHub Desktop.
Save kyleaparker/b9fd3e4f7532f9f19658 to your computer and use it in GitHub Desktop.
[Shopify] Display articles alphabetically
{% assign articles = blogs.news.articles | sort: 'title' %}
{% for article in articles %}
{{ article.title }}<br>
{% endfor %}
@kufeiko
Copy link

kufeiko commented Mar 30, 2015

Unfortunatelly, Shopify will not allow you to paginate that :(

@callaginn
Copy link

callaginn commented Oct 5, 2023

Yeah, it's a really frustrating issue that still isn't fixed. 😬 Know it's a bit late, but here's one way to work around it:

{%- capture articleList -%}
{%- for article in blog.articles -%}{{ article.title | handleize }}{% unless forloop.last %},{% endunless %}{%- endfor -%}
{%- endcapture -%}

<style type="text/css">
    /* List articles in alphabetical order */
    {% for articleName in articleList %}
        .location-{{ articleName }} {
            order: {{ forloop.index }};
        }
    {% endfor %}
</style>

{% for article in blog.articles %}
    <a class="location-{{ article.title | handleize }}" href="{{ article.url }}">
        {{ article.title }}
    </a>
{% endfor %}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment