Query by Tag

This page gives you a couple of examples of how to query documents by their tags. If you want to query all of the documents with a certain tag, then you just need to specify the document.tags.

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.

Query by a Certain Tag

Here is an example of a query of all the documents with the tag "Featured".

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

Query all of Multiple Tags

This example shows how to query all of the documents with either the tag "Tag 1" or "Tag 2" by using the any predicate.

Copy
api.query(
    Prismic.Predicates.any('document.tags', ['Tag 1', 'Tag 2'])
).then(function(response) {
    // response is the response object, response.results holds the documents
});