๐Ÿ”ฎ Sanity Create is here. Writing is reinvented. Try now, no developer setup

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?