How to Change a Post's Position in the Object of Posts

5 replies
Last updated: Oct 3, 2022
is there a way to change a posts position in the object of posts? I have the order-documents plugin, would be nice if the order i change them in reflects the posts positions on my front-end, been googling but alas i cannot find anything. More info in thread.
Sep 30, 2022, 2:11 PM
I think i need to include
 | order(order asc)
but i cannot get it to work in my query.

*[_type == "post"  && references(*[ title == "frontpage" ]._id )]
Sep 30, 2022, 2:13 PM
You can get the documents in the order you've set if you order by
orderRank
. Here's the example from the plugin's docs:
*[_type == "category"]|order(orderRank)
Sep 30, 2022, 4:29 PM
Thank you so much, this seems even better for the content creator to use.
Oct 3, 2022, 7:10 AM
Works like a charm πŸ™‚
Oct 3, 2022, 9:08 AM
Fantastic!
Oct 3, 2022, 3:34 PM

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Was this answer helpful?