Use Multiple Predicates

This page shows how to use two or more predicate in a single query.

Before Reading

This page assumes that you've already imported the Prismic library and retrieved the api object. If you want to learn how to do this, then refer to the How to Query the API page.

Example 1

Here's an example that uses two predicates. It shows how to query all of the documents of the custom type "blog_post" with the tag "featured".

Copy
api.query([
    Prismic.Predicates.at('document.type', 'blog_post'),
    Prismic.Predicates.at('document.tags', ['featured'])
]).then(function(response) {
    // response is the response object, response.results holds the documents
});

Example 2

Here's another example that queries all of the documents of the custom type "employee" excluding those with the tag "manager".

Copy
api.query([
    Prismic.Predicates.at('document.type', 'employee'),
    Prismic.Predicates.not('document.tags', ['manager'])
]).then(function(response) {
    // response is the response object, response.results holds the documents
});