👀 Our most exciting product launch yet 🚀 Join us May 8th for Sanity Connect

How to get only the published results on GROQ in Sanity.io.

3 replies
Last updated: Feb 12, 2024
Hi everyoneHow I can to do to get only the published results on GROQ?

Thanks
Feb 12, 2024, 8:15 AM
Add this as a condition to your GROQ-query:
!(_id in path('drafts.**'))
Feb 12, 2024, 9:45 AM
This will exclude all the drafts, leaving only the published content.
Feb 12, 2024, 9:45 AM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?