Unlock seamless workflows and faster delivery with our latest releases - Join the deep dive

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?