What's your biggest current challenge? Have your say in Community Polls along the right column.

Re: Sorting blog articles

How can I sort blog articles from newest to oldest on a client's site?

tablocreative
Shopify Partner
15 0 3

I have 3 separate blogs on my client's Shopify site. I needed to create a page that would list all articles, kind of like an "all categories" listing.
Please stop me now if there's a simpler way to do this within Shopify and just use actual categories, but this is the only solution I could find online.

I simply want to sort through all the articles so the newest are at the top. Right now, it is listing all articles from the 'fashion' blog first, then from the 'design' blog, and so on. Here is my code:

<div class="col-xs-12 col-sm-9 col-md-9 col-main">
{% assign blog_handles = "fashion,design,music" | split: "," %}
	{% for handle in blog_handles %}
		{% for article in blogs[handle].articles %}
		<div class="content-blogs">
             		<h1><a href="{{ article.url }}">{{ article.title }}</a></h1>
			{% if paginate.pages > 1 %}
      			<div class="text-center">
        			{% include 'pagination' %}
      			</div>
     			{% endif %}
		</div>
		{% endfor %}
	{% endfor %}
Replies 4 (4)

JoePichardo
Shopify Partner
10 0 2

Hey tablocreative, I've actually made an app to drag and drop blogs into the positions you would like. Here's the link to the Shopify App: Article Organizer Pro

markdc
Shopify Partner
23 0 22

I'm also looking for a liquid solution to this.

markdc
Shopify Partner
23 0 22

Update: I found working code to do this here.

nhcon
Shopify Partner
14 0 7

Hello.. I can't find the working code at that link. Any chance you could repost?

 

Thanks!