Get pages by custom tags

Hi everyone!


I have a page type with a "blog_page" name and want to create tags for them. I created a custom type "blog_tags". After this, I added a "group field" with a "tags" name to a "blog_page" and a "content relationship" with a "tag" name inside the "group field".

Now I want to make a request by uid of the "blog_tags" and retrieve all related "blog_page" pages but IDK how.

For reference I used this topic

This is a screenshot from the blog_page:

What steps have I taken?

I asked ChatGPT4o and it gave me this answer.

 const blogPages = await client.getAllByType('blog_page', {
      filter:'my.blog_page.tags.tag', tagUID),
      fetchLinks: ['blog_page.title', 'blog_page.content'] // Adjust according to your blog_page custom type fields

For tagUid I am using this code:

const newTags = await client.getByType("blog_tags");
const tagUID = newTags.results[0].uid;

I was trying to use this code but it is always returns empty results. How make it work?

Prismic version:
"@prismicio/client": "^7.3.1",

Hey @syndicateua,

The code from ChatGPT is almost correct. However, instead of the uid, you should use the id. Let me know if this works for you.


This is my mistake because I wrote this part of the code. ChatGPT gave me only the part with the getAllByType
Maybe I missed somewhere in the docs that I should pass id for the Content Relationship type...

1 Like

We'll take a look at making this more clear in the docs!