Sort by Metafield Date

Shopify Partner
12 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
1841 170 481

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
Shopify Partner
12 0 0

Ah okay, 

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

 

0 Likes
Highlighted
Shopify Expert
9542 28 1310

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
1841 170 481

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

I turn coffee in to code - since 1998
0 Likes
Shopify Partner
12 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