
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeTo query for all authors and exclude the author of the current article, you'd use GROQ's filter operators combined with reference comparison. Here's how:
Basic approach - if you know the author ID:
*[_type == "author" && _id != $currentAuthorId]Within an article query using the ^ operator:
The ^ operator refers to the enclosing document, which is perfect for this use case:
*[_type == "article" && _id == "current-article-id"]{
title,
author->{name, bio},
"otherAuthors": *[_type == "author" && _id != ^.author._ref]{
name,
bio
}
}In your application code:
// Pass the author ID as a parameter
const otherAuthors = await client.fetch(
`*[_type == "author" && _id != $authorId]`,
{ authorId: currentArticle.author._ref }
)Complete example for an article page:
*[_type == "article" && slug.current == $slug][0]{
title,
body,
author->{
_id,
name,
bio,
image
},
"otherAuthors": *[_type == "author" && _id != ^.author._ref]{
_id,
name,
bio,
image
}
}The key concepts here:
!= operator - The "not equal" operator filters out matching values^ operator - References the enclosing/parent document in nested queries.\_ref - When comparing references, use the _ref property which contains the referenced document's _idThis pattern works whether the author field is a direct reference or part of a more complex structure. Just adjust the path to match your schema (e.g., ^.author._ref vs ^.authors[0]._ref for array references).
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.
Content operations
Content backend


The only platform powering content operations
By Industry


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store