πŸ‘€ Our most exciting product launch yet πŸš€ Join us May 8th for Sanity Connect

How to Return Blog Posts by Slug Excluding the Slug that is being Passed to the Query

2 replies
Last updated: Aug 3, 2021
Hi everyone, it's me again. πŸ˜›
I trying to return blog posts by slug excluding the slug that is being passed to the query.

I've tried the following without success:


*[_type == 'post' && slug.current match !$slug]
*[_type == 'post' && !slug.current match $slug]

Aug 3, 2021, 12:15 PM
Have you tried
*[_type == 'post' && !(slug.current match $slug)]
Aug 3, 2021, 1:39 PM
user A
Thank you, that worked. 😎 πŸŽ‰
Aug 3, 2021, 2:12 PM

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?