Sort by Metafield Date

New Member
5 0 0

Hello there, 

For a Shopify site I'm making, we are using the blog feature to instead promote events. We've assigned a date metafield to each event post. I wanted to know if there was a way to sort these event posts by the date of the event as opposed to through the publish date. 

 

We are using Metafield Manager for our metafields and when calling the date metafield it outputs a long number unless properly formatted by liquids own date format syntax. 

0 Likes
Shopify Partner
1592 121 329

Won't be possible using Liquid sort filter.

 

You'd need to resort to loading all articles and the metafield value then use JavaScript.

I turn coffee in to code - since 1998
0 Likes
New Member
5 0 0

Ah okay, 

Would I do that by loading in all the JSON values into an array? 

 

0 Likes
Highlighted
Shopify Expert
9420 11 1262

You can - to a degree - sort by metafield value. There's an old post here that talks about the concept but the value used has to be pretty specific, and there'll be a limit to the amount of objects you can sort.

★ Winning Partner of the Build a Business competition. ★ http://freakdesign.com.au
1 Like
Shopify Partner
1592 121 329

I stand corrected and schooled - that's quite nifty @Jason!

I turn coffee in to code - since 1998
0 Likes
New Member
5 0 0

I'm looking through the post you linked to, @Jason but I'm not entirely sure where you define what Metafield value to sort by? 

0 Likes